| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-std=c++2a" } |
| 3 |
|
| 4 |
extern "C" void abort (); |
| 5 |
namespace std { |
| 6 |
constexpr inline bool |
| 7 |
is_constant_evaluated () noexcept |
| 8 |
{ |
| 9 |
return __builtin_is_constant_evaluated (); |
| 10 |
} |
| 11 |
} |
| 12 |
|
| 13 |
int |
| 14 |
main () |
| 15 |
{ |
| 16 |
constexpr int a = 5; |
| 17 |
auto b = [] (int n) consteval { return n + a + std::is_constant_evaluated (); }; |
| 18 |
int c = b (4); |
| 19 |
if (c != 10) |
| 20 |
abort (); |
| 21 |
auto d = [] () consteval { return a + std::is_constant_evaluated (); }; |
| 22 |
int e = d (); |
| 23 |
if (e != 6) |
| 24 |
abort (); |
| 25 |
constexpr int f = d (); |
| 26 |
if (f != 6) |
| 27 |
abort (); |
| 28 |
static_assert (d () == 6); |
| 29 |
} |