aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/is-constant-evaluated4.C
blob: 809e3d2e687c1aee35f53207c87278630909adb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// P0595R2
// { dg-do compile { target c++14 } }

namespace std {
  constexpr inline bool
  is_constant_evaluated () noexcept
  {
    return __builtin_is_constant_evaluated ();
  }
}

constexpr int
foo () noexcept
{
  return std::is_constant_evaluated () ? 5 : 12;
}

static_assert (std::is_constant_evaluated (), "");
static_assert (foo () == 5, "");