Is constexpr a “hint” (like inline) or “a binding request” to the compiler?
Is constexpr an indicator for the compiler or does it mandate a behaviour ? The example at hand is the following : template<typename T> std::size_t constexpr getID() { return typeid(T).hash_code(); } hash_code is a runtime constant, yet this snippet would compile even though a compile time evaluation is requested with constexpr . Only after the return value is used where a compile time constant is expected, would we get noticed that this is not usable as a constexpr function . So is constexpr a "hint" (much like the inline keyword) or "a binding request" to the compiler ? From the C++11 Wiki