Rob*_*ert 9 c++ hash typeid compile-time
我想在编译时根据派生类型为类生成哈希.今天我生成它像:
template<class Type>
class TypeBase
{
public:
static const unsigned s_kID;
};
template<class Type>
const unsigned TypeBase<Type>::s_kID = hash(typeid(Type));
Run Code Online (Sandbox Code Playgroud)
但这会产生(非常不必要)运行时初始化代码(hash(..)函数根据std :: type_info :: name()执行简单的哈希)
想法?
| 归档时间: |
|
| 查看次数: |
2732 次 |
| 最近记录: |