std::is_constant_evaluated() is one the many new small features of C++20. Specified in P0595R2, this function is available in the <type_traits&g...
For further actions, you may consider blocking this person and/or reporting abuse
That's interesting! What would be an example of where you'd want a function to change depending on whether it's compile or runtime?
There is an example in the proposal to compute the power of a number.
There is a possible application case in my current project. We have a custom type for fixed-point numbers. We have a function to compute sine and cosine for this type, thanks to a lookup table of 1024 values. This is faster (to compute) but less accurate (especially if the table is small).
We may use
std::is_constant_evaluatedhere: