Home Dashboard Directory Help
Search

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


Status: 

Closed
 as Fixed Help for as Fixed


1
0
Sign in
to vote
Type: Bug
ID: 687935
Opened: 9/12/2011 12:36:50 AM
Access Restriction: Public
Moderator Decision: Sent to Engineering Team for consideration
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

class C
{
public:
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
Details
Sign in to post a comment.
Posted by Microsoft on 9/13/2011 at 10:08 AM
Hi:
    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(http://support.microsoft.com)
Sign in to post a workaround.