Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Intelligent suggestions for perfect forwarding
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

awishnick
New Member

2 Posts

Posted - May 16 2012 :  11:39:54 PM  Show Profile  Reply with Quote
C++11 has some new functions that use perfect forwarding. The most common example that comes up for me is make_shared. Here's an example:


class MyClass {
    MyClass(int a, char b, float c);
    explicit MyClass(short s);
};
auto p = std::make_shared<MyClass>(2, 'h', 5.0f);


When I type "std::make_shared<MyClass>", I would really like to see autocomplete for the MyClass constructors. In other words, when I type "make_shared<MyClass>(", I would like it to behave as if I had typed "new MyClass(".

Instead, once I type the opening parentheses, I see code completion for the make_shared function, which looks something like (since VS doesn't support variadic templates yet):


template <class Type>
shared_ptr<Type> make_shared();
template <class Type, class A1>
shared_ptr<Type> make_shared(A1&& a1);
template <class Type, class A1, class A2>
shared_ptr<Type> make_shared(A1&& a1, A2&& a2);


I know in general it isn't really possible to inspect a function that does perfect forwarding and determine what's being done. Maybe there are more sophisticated things that could be done, but I think it would be extremely useful to allow the user to specify that a function has these semantics. In other words, have a list of functions in some configuration, containing make_shared by default. If this is a function template, with the first template argument as a class, explicitly specified, and the rest as rvalue reference parameters, show autocompletion for constructors of the class that is the first template argument. In other words, show the constructors of MyClass in my example.

So, if the user types "function_name<SomeClass>(", and function_name is in that list, autocomplete would show results for constructors of SomeClass.

Thanks for your time!

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - May 21 2012 :  4:28:57 PM  Show Profile  Reply with Quote
Do you have a lot of functions that do this? Or would trying to add some form of special case handling for std::make_shared be enough for now?

As soon as you get into multiple parameters to the template, I suspect we are going to hit a massive pile of edge cases here, and that is before we start thinking about people wrapping this in macro's.

zen is the art of being at one with the two'ness
Go to Top of Page

awishnick
New Member

2 Posts

Posted - May 23 2012 :  2:33:03 PM  Show Profile  Reply with Quote
I don't have a lot of functions that do this. I can imagine that it's way easier to special-case this for make_shared than to support this in general. I think it would be great to have general support, but special casing make_shared would be extremely useful on its own, and probably cover 90% of the cases I run into.

Thanks!
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - May 25 2012 :  1:15:47 PM  Show Profile  Reply with Quote
Thank you for the update, I have put in a feature request to special case support for make_shared to see what our developers make of it:

case=66895

zen is the art of being at one with the two'ness
Go to Top of Page

burbelgruff
New Member

8 Posts

Posted - Mar 08 2017 :  08:36:07 AM  Show Profile  Reply with Quote
This is now more relevant than ever. Whenever you have a function
template<typename... Args>
void ForwardingFunction(Args...&& args)
{
return MyForwardedCall(std::forward<Args>(args)...);
}

or, as is the case for std::make_shared:
template<typename T, typename... Args>
T make_shared(Args...&& args)
{
//Simplified
T* value = new T(std::forward<Args>(args)...);
return value;
}

we want to also forward autocompletion. This scenario is increasingly common, and a solution to this would greatly improve productivity.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18750 Posts

Posted - Mar 08 2017 :  1:58:25 PM  Show Profile  Reply with Quote
Thank you for your interest and explanation, knowing who is interested in what helps us to prioritise the order in which we do things. I have added a note to the case about your interest in this, but unfortunately I cannot yet give you an estimate for if or when this will be done.

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000