Foreword--I love C++ lambda, if possible I will use it everywhere.
Now I have a lambda requirement, I need to a __stdcall lambda. But I get the following error message:
error C2664: 'EnumWindows' : cannot convert parameter 1 from '`anonymous-namespace'::<lambda1>' to 'WNDENUMPROC'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Anybody can help me? Here is my code(EnumWindowsProc is in the function scope):
auto EnumWindowsProc =
[&](HWND hwnd, LPARAM lParam) mutable -> bool
{
return true;
};
EnumWindows(EnumWindowsProc, NULL);
I just noticed you have the
visual studio 2010
tag. Stateless lambdas were implemented in VC11. Reference:Also, note that this conversion happens when there is no capture specification as mentioned in the second bolded quote.