My Project
Functions
is_constant_evaluated.hpp File Reference

Go to the source code of this file.

Functions

constexpr bool bsl::is_constant_evaluated () noexcept
 Detects whether the function call occurs within a constant-evaluated context. Returns true if the evaluation of the call occurs within the evaluation of an expression or conversion that is manifestly constant-evaluated; otherwise returns false. More...
 

Detailed Description

Function Documentation

◆ is_constant_evaluated()

constexpr bool bsl::is_constant_evaluated ( )
noexcept

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

#include <bsl/debug.hpp>
namespace bsl
{
inline void
example_is_constant_evaluated_overview() noexcept
{
if constexpr (bsl::is_constant_evaluated()) {
bsl::print() << "success\n";
}
if (!bsl::is_constant_evaluated()) {
bsl::print() << "success\n";
}
}
}
Returns
Returns true if the evaluation of the call occurs within the evaluation of an expression or conversion that is manifestly constant-evaluated; otherwise returns false.