Ambiguous call to overloaded function in c++ when using lambdas - by rzlwatboa

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.

Sign in
to vote
ID 687935 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 9/12/2011 12:36:50 AM
Access Restriction Public


class C 
   void M(string t) {} 
   void M(function<string()> func) {} 
void TestMethod(function<void()> func) {} 
int _tmain(int argc, _TCHAR* argv[]) 
   TestMethod([] () { 
      C c; 
      c.M([] () -> string { //compiler error C2668 ('function':ambiguous call to overloaded function M) 
          return ("txt"); 

     C c2; 
      c.M([] () -> string { // no compiler error
      return ("txt"); 

    return 0; 

I don't know why the first call to function M can't be compiled. I think this is a bug of the compiler
Sign in to post a comment.
Posted by Microsoft on 9/13/2011 at 10:08 AM
    A fix for this issue has been checked into the compiler sources. The fix should show up in the next release of Visual C++.

Xiang Fan
Visual C++ Team
Posted by MS-Moderator07 [Feedback Moderator] on 9/12/2011 at 6:19 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 9/12/2011 at 12:39 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(