FairRoot
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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
}
func_type
int( func_type)
Definition:
cxx11-test-funcptr-to-lambda-conversion.cpp:4
B
Definition:
cxx11-test-funcptr-to-lambda-conversion.cpp:13
main
int main(void)
Definition:
cxx11-test-__func__.cpp:1
A::foo
int foo(func_type *f)
Definition:
cxx11-test-funcptr-to-lambda-conversion.cpp:7
A
Definition:
cxx11-test-funcptr-to-lambda-conversion.cpp:5
B::bar
int bar(A &a)
Definition:
cxx11-test-funcptr-to-lambda-conversion.cpp:15
FairRoot
cmake
checks
cxx11-test-funcptr-to-lambda-conversion.cpp
Generated on Mon Mar 8 2021 12:14:05 for FairRoot by
1.8.5