gcc/ChangeLog:
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1z / constexpr-lambda17.C
blob44bd2b83f945e9c0900279e8e385715599bbe7f4
1 // PR c++/78131
2 // { dg-options -std=c++17 }
4 template <typename TF>
5 constexpr auto f(TF)
7     return [](auto...) constexpr { return true; };
8 }   
10 // Compiles and works as intended.
11 template <typename T0>
12 void ok_0(T0)
14     static_assert(f([](auto x) -> decltype(x){})(T0{}));
17 // Compiles and works as intended.
18 template <typename T0>
19 void ok_1(T0)
21     constexpr auto a = f([](auto x) -> decltype(x){})(T0{});
22     if constexpr(a) { }
25 // Compile-time error!
26 template <typename T0>
27 void fail_0(T0)
29     if constexpr(f([](auto x) -> decltype(x){})(T0{})) { }