gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated7.C
raw| 1 | // P0595R2 |
| 2 | // PR c++/88977 |
| 3 | // { dg-do compile { target c++11 } } |
| 4 | |
| 5 | namespace std { |
| 6 | constexpr inline bool |
| 7 | is_constant_evaluated () noexcept |
| 8 | { |
| 9 | return __builtin_is_constant_evaluated (); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | template<bool B> constexpr bool foo () { return B; } |
| 14 | |
| 15 | constexpr bool x = foo<std::is_constant_evaluated ()> (); |
| 16 | constexpr bool y = foo<__builtin_is_constant_evaluated ()> (); |
| 17 | static_assert (x, ""); |
| 18 | static_assert (y, ""); |