Calling a bound lambda through a std::function variable - by nashah

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.


5
0
Sign in
to vote
ID 618807 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 11/2/2010 9:19:11 AM
Access Restriction Public

Description

I am unable to compile a small snippet of C++ code that tries to call a bound lambda function through a std::function variable.
Sign in to post a comment.
Posted by Microsoft on 2/16/2011 at 9:55 PM
Hi,

Thanks for reporting this bug. We've fixed it, and the fix will be available in VC11. Here's an example:

C:\Temp>type meow.cpp
#include <functional>
#include <iostream>
#include <ostream>
#include <string>
using namespace std;

int main() {
    int value = 42;

    auto myBoundLambda = [&](const string& header) {
        cout << header << value << endl;
    };

    function<void ()> myFunction = bind(myBoundLambda, "Answer to life is: ");

    myFunction();

    value = 1729;

    myFunction();
}

C:\Temp>cl /EHsc /nologo /W4 meow.cpp
meow.cpp

C:\Temp>meow
Answer to life is: 42
Answer to life is: 1729

If you have any further questions, feel free to E-mail me at stl@microsoft.com .

Stephan T. Lavavej
Visual C++ Libraries Developer
Posted by Microsoft on 11/2/2010 at 7:13 PM
Thanks for your feedback. We are routing 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 Microsoft on 11/2/2010 at 9:23 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)