blob: 44bd2b83f945e9c0900279e8e385715599bbe7f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// PR c++/78131
// { dg-options -std=c++17 }
template <typename TF>
constexpr auto f(TF)
{
return [](auto...) constexpr { return true; };
}
// Compiles and works as intended.
template <typename T0>
void ok_0(T0)
{
static_assert(f([](auto x) -> decltype(x){})(T0{}));
}
// Compiles and works as intended.
template <typename T0>
void ok_1(T0)
{
constexpr auto a = f([](auto x) -> decltype(x){})(T0{});
if constexpr(a) { }
}
// Compile-time error!
template <typename T0>
void fail_0(T0)
{
if constexpr(f([](auto x) -> decltype(x){})(T0{})) { }
}
|