Any type_traits or method could find out the parameters is a constexpr or not?
Example
size_t fibo_runtime(size_t num)
{
//implementation
}
constexpr
The very nature of constant expression (constexpr
) is to be constant. So runtime evaluation or not, they will not change any of their behavior and the evaluation will never be done at runtime.
If you use a constexpr
function at runtime (which is not simply by calling it straightforwardly), then it will be called as a normal function, as the expression cannot be resolved by nature as constant during runtime.
If you want to achieve some different implementation depending on compile-time or runtime it will (if you achieve it) be really disturbing for the developer as the function would not have the same behavior depending on how you call it ! Thus it becomes clear that such behavior could not / will not / should not be implemented.
If you want to specialize a function for compile-time computation, use a different function to clearly state your intentions.