gcc/testsuite/g++.dg/cpp1z/constexpr-lambda18.C
raw| 1 | // PR c++/82570 |
| 2 | // { dg-do compile { target c++17 } } |
| 3 | |
| 4 | template< typename Body > |
| 5 | inline void iterate(Body body) |
| 6 | { |
| 7 | body(10); |
| 8 | } |
| 9 | |
| 10 | template< typename Pred > |
| 11 | inline void foo(Pred pred) |
| 12 | { |
| 13 | iterate([&](int param) |
| 14 | { |
| 15 | if (pred(param)) |
| 16 | { |
| 17 | unsigned char buf[4]; |
| 18 | buf[0] = 0; |
| 19 | buf[1] = 1; |
| 20 | buf[2] = 2; |
| 21 | buf[3] = 3; |
| 22 | } |
| 23 | }); |
| 24 | } |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | foo([](int x) { return x > 0; }); |
| 29 | return 0; |
| 30 | } |