我想在编译时根据其派生类型为类生成哈希。今天我像这样生成它:
template<class Type>
class TypeBase
{
public:
static const unsigned s_kID;
};
template<class Type>
const unsigned TypeBase<Type>::s_kID = hash(typeid(Type));
但这会生成(非常不必要的)运行时初始化代码( hash(..) 函数基于 std::type_info::name() 进行简单的哈希)
想法?