fork download
  1. auto lambda = [](int x) { return x + 3; };
  2.  
  3. namespace NS { class CL{}; }
  4.  
  5. void func(NS::CL& c) {}
  6.  
  7. int main() { func(lambda); }
  8.  
  9.  
  10.  
  11. /* MSVC 2010 error message:
  12.  *
  13.  * lambderp.cpp(7) : error C2664: 'func' : cannot convert parameter 1 from
  14.  * '`anonymous-namespace'::<lambda0>' to 'NS::CL &'
  15.  *
  16.  *
  17.  * MSVC 2015 error message:
  18.  *
  19.  * lambderp.cpp(7): error C2664: 'void func(NS::CL &)': cannot convert argument 1 from
  20.  * '<lambda_fa8b6adcd63ef1ed2107ab0e1400907b>' to 'NS::CL &'
  21.  */
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:7:25: error: invalid initialization of reference of type 'NS::CL&' from expression of type '<lambda(int)>'
 int main() { func(lambda); }
                         ^
prog.cpp:5:6: note: in passing argument 1 of 'void func(NS::CL&)'
 void func(NS::CL& c) {}
      ^
stdout
Standard output is empty