c++ - operator + on Lambda -



c++ - operator + on Lambda -

can help me pointing out why not work in vs2013?

auto p = +[]() -> void { std::cout << "hello, world!\n"; }; p(); source_file.cpp(7) : error c2593: 'operator +' ambiguous 'built-in c++ operator+(void (__cdecl *)(void))' or 'built-in c++ operator+(void (__stdcall *)(void))' or 'built-in c++ operator+(void (__fastcall *)(void))' or 'built-in c++ operator+(void (__vectorcall *)(void))'

this legal operator force-cast lambda

5.1.2 lambda expressions [expr.prim.lambda]

6 closure type lambda-expression no lambda-capture has public non-virtual non-explicit const conversion function pointer function having same parameter , homecoming types closure type’s function phone call operator. value returned conversion function shall address of function that, when invoked, has same effect invoking closure type’s function phone call operator.

how can tell compiler conversion should use?

apparently vc++ bug. there seems no other way explicitly cast:

+ static_cast< void(*)() >( []{} ); // empty lamba without loss of generality

unfortunately, magic lost this.

c++ c++11 lambda

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -