[#absl-is_constant_evaluated]
= xref:absl.adoc[absl]::is&lowbar;constant&lowbar;evaluated
:relfileprefix: ../
:mrdocs:

Detects whether the function call occurs within a constant&hyphen;evaluated context&period; Returns true if the evaluation of the call occurs within the evaluation of an expression or conversion that is manifestly constant&hyphen;evaluated&semi; otherwise returns false&period;

== Synopsis

Declared in `&lt;absl&sol;meta&sol;type&lowbar;traits&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
constexpr
bool
is&lowbar;constant&lowbar;evaluated() noexcept;
----

== Description

This function is implemented in terms of `std&colon;&colon;is&lowbar;constant&lowbar;evaluated` for c&plus;&plus;20 and up&period; For older c&plus;&plus; versions, the function is implemented in terms of `&lowbar;&lowbar;builtin&lowbar;is&lowbar;constant&lowbar;evaluated` if available, otherwise the function will fail to compile&period;

Applications can inspect `ABSL&lowbar;HAVE&lowbar;CONSTANT&lowbar;EVALUATED` at compile time to check if this function is supported&period;

Example&colon;

constexpr MyClass&colon;&colon;MyClass(int param) &lcub; &num;ifdef ABSL&lowbar;HAVE&lowbar;CONSTANT&lowbar;EVALUATED if (!absl&colon;&colon;is&lowbar;constant&lowbar;evaluated()) &lcub; ABSL&lowbar;LOG(INFO) &lt;&lt; &quot;MyClass(&quot; &lt;&lt; param &lt;&lt; &quot;)&quot;&semi; &rcub; &num;endif &sol;&sol; ABSL&lowbar;HAVE&lowbar;CONSTANT&lowbar;EVALUATED &rcub;

Upstream documentation&colon;

http&colon;&sol;&sol;en&period;cppreference&period;com&sol;w&sol;cpp&sol;types&sol;is&lowbar;constant&lowbar;evaluated http&colon;&sol;&sol;gcc&period;gnu&period;org&sol;onlinedocs&sol;gcc&sol;Other&hyphen;Builtins&period;html&num;&colon;&#126;&colon;text&equals;&lowbar;&lowbar;builtin&lowbar;is&lowbar;constant&lowbar;evaluated

== Return Value

`true` if called within a constant&hyphen;evaluated context, `false` otherwise&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
