FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cxx11-test-funcptr-to-lambda-conversion.cpp
Go to the documentation of this file.
1 
2 // test funcptr to lambda conversion in such pattern. Some old compiler may not compile the following code
3 // comment : direct lambda assignment to function ptr in the main() may still works for the same compilers, however.
4 using func_type = int();
5 struct A
6 {
7  int foo(func_type* f)
8  {
9  return f();
10  }
11 };
12 
13 struct B
14 {
15  int bar(A& a)
16  {
17  return a.foo([](){return 42;});
18  }
19 };
20 
21 int main()
22 {
23  A a;
24  B b;
25  return (42==b.bar(a)) ? 0 : 1;
26 }
int main(void)