compile-time string hashing

前端 未结 4 497

I need to use a string as the ID to obtain some object. At implement this in a run-time, and works well. But this makes the static type checking impossible, for obvious rea

4条回答
  •  感情败类
    2020-12-31 10:34

    Templates can be instantiated with any external symbol, therefore this should work as expected:

    external char const* object_method = "object.method";
    ... = hash_cstring::value;
    

    (given the template hash_cstring<> is able to deal with pointer values).

提交回复
热议问题