gcc/testsuite/g++.dg/cpp1z/constexpr-if25.C
raw| 1 | // PR c++/86740 |
| 2 | // { dg-do compile { target c++17 } } |
| 3 | |
| 4 | struct Constant |
| 5 | { |
| 6 | static constexpr int value = 0; |
| 7 | }; |
| 8 | template<typename F> |
| 9 | void invokeWithConstant(F &&f) |
| 10 | { |
| 11 | f(Constant{}); |
| 12 | } |
| 13 | int foo() |
| 14 | { |
| 15 | int count = 0; |
| 16 | invokeWithConstant |
| 17 | ([&] (auto id1) |
| 18 | { |
| 19 | invokeWithConstant |
| 20 | ([&] (auto id2) |
| 21 | { |
| 22 | if constexpr (id1.value == 0 && id2.value == 0) |
| 23 | [&] { count = 1; } (); |
| 24 | }); |
| 25 | }); |
| 26 | return count; |
| 27 | } |