windows - how to use __stdcall to qualify C++ lambda? -


foreword--i love c++ lambda, if possible use everywhere.

now have lambda requirement, need __stdcall lambda. following error message:

 error c2664: 'enumwindows' : cannot convert parameter 1 '`anonymous-namespace'::<lambda1>' 'wndenumproc' 1>          no user-defined-conversion operator available can perform conversion, or operator cannot called 

anybody can me? here code(enumwindowsproc in function scope):

        auto enumwindowsproc =              [&](hwnd hwnd, lparam lparam) mutable -> bool         {             return true;         };         enumwindows(enumwindowsproc, null); 

i noticed have visual studio 2010 tag. stateless lambdas implemented in vc11. reference:

after lambdas voted working paper (v0.9) , mutable lambdas added (v1.0), standardization committee overhauled wording, producing lambdas v1.1. this happened late implement in vc10, we've implemented in vc11. lambdas v1.1 wording clarifies should happen in corner cases referring static members, or nested lambdas. fixes bunch of bugs triggered complicated lambdas. additionally, stateless lambdas convertible function pointers in vc11. isn't in n2927's wording, count part of lambdas v1.1 anyways. it's fdis 5.1.2 [expr.prim.lambda]/6: "the closure type lambda-expression no lambda-capture has public non-virtual non-explicit const conversion function pointer function having same parameter , return types closure type’s function call operator. value returned conversion function shall address of function that, when invoked, has same effect invoking closure type’s function call operator." (it's better that, since we've made stateless lambdas convertible function pointers arbitrary calling conventions. important when dealing apis expect __stdcall function pointers , forth.)

also, note conversion happens when there no capture specification mentioned in second bolded quote.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -