Check if a function call can be resolved in compile-time

Viewed 127

Basically, I need to check if a function call can be resolved in compile-time or not and based on that, generate one constexpr function for compile-time use and one non-constexpr function for run-time use. Is it even possible in C++14?

Example

I want to use (probably extensively optimized) std::abs() for run-time calls but, if possible, I want to use my own constexpr implementation of abs().


I know that g++ already implements a lot of functions as constexpr, but I want clang++ compatibility as well. Not to mention, this is not limited to abs, I would possibly use it for other cases as well.

0 Answers
Related