Arclight icon indicating copy to clipboard operation
Arclight copied to clipboard

Math functions are wrongly declared constexpr

Open ghost opened this issue 3 years ago • 2 comments

All math functions should be constexpr since there is no reason for them to be non-compile-time-evaluatable. However, std defines them as non-constexpr due to potential side effects.

A solution would be to use intrinsics where applicable. On runtime, this seems to be the best solution. When an architecture does not support a certain operation or whenever an intrinsic is non-constexpr, we must resort to optimized algorithms.

To check if the function is currently compile-time evaluated, std::is_constant_evaluated or (as soon as c++23 is supported) if consteval may be used in such contexts.

ghost avatar Jun 21 '21 12:06 ghost