是constexpr编译器的指标还是强制执行行为?
手头的例子如下:
template<typename T>
std::size_t constexpr getID() { return typeid(T).hash_code(); }
Run Code Online (Sandbox Code Playgroud)
hash_code是一个运行时常量,但即使请求编译时评估,此片段也会编译constexpr.只有在期望编译时常量的返回值之后,才会注意到这不能用作constexpr函数.
那么是constexpr一个"提示"(很像inline关键字)或编译器的"绑定请求"?