locked
an enclosing-function local variable cannot be referenced in a lambda body unless it is in the capture list

    Question

  • I'm new to programming WinRT components in C++ and I'm having trouble understanding why the following code does not work or compile:

    IAsyncOperation<String^>^ HttpClient::Get(String^ url)
    {
    	return create_async([]() -> task<String^> {
    		return GetInternal(url);
    	});
    }
    
    task<String^> HttpClient::GetInternal(String^ url)
    {
    	return task<String^>( []() {
    		return "test";
    	});
    }


    Wednesday, June 18, 2014 4:55 PM

Answers