compile-time string hashing

前端 未结 4 505

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条回答
  •  Happy的楠姐
    2020-12-31 10:29

    In case anyone is interested, I walk through how to create a compile time hash of Murmur3_32 using C++11 constexpr functions and variadic templates here:

    http://roartindon.blogspot.sg/2014/10/compile-time-murmur-hash-in-c.html

    Most of the examples I've seen deal with hashes that are based on consuming one character of the string at a time. The Murmur3_32 hash is a bit more interesting in that it consumes 4 characters at a time and needs some special case code to handle the remaining 0, 1, 2 or 3 bytes.

提交回复
热议问题