我是 lambdas 新手,我很难理解以下 lambda 表达式的参数列表是如何工作的。
该代码是 facebook 身份验证方法的一部分:
---------------- begin snippet ------------------
auto webAuthenticationOperation = WebAuthenticationBroker::AuthenticateAsync(WebAuthenticationOptions::Default, startURI, endURI);
webAuthenticationOperation->Completed = ref new AsyncOperationCompletedHandler<WebAuthenticationResult^>([output, facebookOutput, facebookToken](IAsyncOperation<WebAuthenticationResult^>^ thisOperation)
{
if (thisOperation->ErrorCode.Value == 0)
----------------some other stuff ---------------
具体来说,我不知道thisOperation实际上是如何引用当前正在处理的 WebAuthenticationResult 的。
我将块读为:
1.) 启动异步身份验证
2.) 认证完成后,运行 lambda 定义的函数
但是 lambda 函数需要了解这个特定的身份验证操作(我假设有某种结果会在完成后返回给我们)。根据 lambda 的参数列表,看起来我们只是声明了一个指向 Web 身份验证结果的指针,而实际上并没有将它指向任何东西。
thisOperation如何最终引用了正确的对象?