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

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 719275 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 1/18/2012 6:01:15 PM
Access Restriction Public
Moderator Decision Sent to Engineering Team for consideration

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.

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)