[meta.const.eval] (original) (raw)

20 General utilities library [utilities]

20.15 Metaprogramming and type traits [meta]

20.15.11 Constant evaluation context [meta.const.eval]

constexpr bool is_constant_evaluated() noexcept;

Returns: true if and only if evaluation of the call occurs within the evaluation of an expression or conversion that is manifestly constant-evaluated ([expr.const]).

[Example 1: constexpr void f(unsigned char *p, int n) { if (std::is_constant_evaluated()) { for (int k = 0; k<n; ++k) p[k] = 0;} else { memset(p, 0, n); } } — _end example_]