Daily bit(e) of C++ | if consteval
Daily bit(e) of C++ ♻️38, The C++23 if statement variant that tests whether the code is invoked from a constant-evaluated context.
C++23 added the if consteval statement, which can test whether the code is invoked from a constant-evaluated context.
This allows for functions that couldn't be constant-evaluated to provide alternate implementations.
Note that while similar, this is different than if constexpr, for which the condition is always evaluated in a constant context.