Home Dashboard Directory Help
Search

Visual C++ compiler won't accept a function pointer as a templated rvalue reference parameter by RobertEngeln


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 719275
Opened: 1/18/2012 6:01:15 PM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

The following code:

struct Foo
{
template <typename T>
Foo(T&&)
{
}
};

void Bar()
{
}

int main()
{
Foo f = Bar;
return 0;
}

Results in the following error message:

error C2440: 'initializing' : cannot convert from 'boost::optional<T> (__cdecl *)(void)' to 'Foo'
         with
         [
             T=int
         ]
         No constructor could take the source type, or constructor overload resolution was ambiguous

It compiles successfully under newer versions of gcc. VC++2010 doesn't seem to think a function pointer can be a parameter to a function accepting a templated rvalue reference parameter, but this is necessary to implement perfect forwarding.

Details
Sign in to post a comment.
Posted by Microsoft on 1/23/2012 at 2:24 PM
Hi: this issue has been fixed. The fix should show up in a future release of Visual C++.

Thank you for reporting the issue.

Jonathan Caves
Visual C++ Compiler Team
Posted by MS-Moderator07 [Feedback Moderator] on 1/18/2012 at 6:37 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by MS-Moderator01 on 1/18/2012 at 6:29 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.