21
Metaprogramming library
[meta]
21.3
Metaprogramming and type traits
[type.traits]
21.3.11
Constant evaluation context
[meta.const.eval]
🔗
constexpr
bool
is_constant_evaluated
(
)
noexcept
;
1
#
Effects
: Equivalent to:
if
consteval
{
return
true
;
}
else
{
return
false
;
}
2
#
[
Example
1
:
constexpr
void
f
(
unsigned
char
*
p,
int
n
)
{
if
(
std
::
is_constant_evaluated
(
)
)
{
// should not be a constexpr if statement
for
(
int
k
=
0
; k
<
n;
+
+
k
)
p
[
k
]
=
0
;
}
else
{
memset
(
p,
0
, n
)
;
// not a core constant expression
}
}
—
end example
]