Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-std-function.C

raw
1 // Test using std::function wrapper.
2 // { dg-do run { target c++11 } }
3 // { dg-skip-if "requires hosted libstdc++ for functional function" { ! hostedlib } }
4
5 #include <functional>
6
7 typedef std::function<int()> FN;
8
9 template<typename T>
10 FN f(T fn)
11 {
12 return [fn]{return fn(2);};
13 }
14
15 int main()
16 {
17 auto fn = f([](int i){return i*21;});
18
19 if (fn() != 42)
20 return 1;
21 return 0;
22 }