Will C++0x support __stdcall or extern “C” capture-nothing lambdas?

后端 未结 3 1219
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 03:07

Yesterday I was thinking about whether it would be possible to use the convenience of C++0x lambda functions to write callbacks for Windows API functions.

For exampl

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 03:24

    The language linkage of the function pointer results from a conversion of a capture-less lambda was not specified in the C++11 standard but was addressed in defect report 1557 which says:

    5.1.2 [expr.prim.lambda] paragraph 6 does not specify the language linkage of the function type of the closure type's conversion function.

    and the resolution was that the language linkage should be C++:

    The closure type for a lambda-expression with no lambda-capture has a public non-virtual non-explicit const conversion function to pointer to function with C++ language linkage (7.5 [dcl.link]). having the same parameter and return types as the closure type's function call operator. The value returned...

    we can find this language in the draft C++14 standard, since the status is DRWP it seems like this does not apply to C++11.

提交回复
热议问题