有没有办法,如何typeid使用 constexpr 在编译时进入变量?
这不起作用,因为std::type_index没有 constexpr ctor
constexpr std::type_index i = typeid(double);
Run Code Online (Sandbox Code Playgroud)
在某种程度上,有:
constexpr const std::type_info &i = typeid(double);
Run Code Online (Sandbox Code Playgroud)
您必须记住typeid返回的是 type const std::type_info &,而不是 a std::type_index。
| 归档时间: |
|
| 查看次数: |
2449 次 |
| 最近记录: |