正しいハッシュ アルゴリズムを実装する必要がありますが、これは C++11 の constexpr 関数を使用して機能する可能性があります。
#include <iostream>
// Dummy hashing algorithm. Adds the value of every char in the cstring.
constexpr unsigned compile_time_hash(const char* str) {
// Modify as you wish
return (*str == 0) ? 0 : (*str + compile_time_hash(str + 1));
}
int main() {
unsigned some_hash = compile_time_hash("hallou");
std::cout << some_hash << std::endl;
}
次に、(この場合は unsigned)ResourcesManager::get
の結果を取るオーバーロードを持つことができます。compile_time_hash
これは明らかに、適用しているハッシュアルゴリズムによって異なります。constexpr を使用して SHA* のようなものを実装するのはかなり面倒です。
constexpr を使用するには、GCC >= 4.6 または clang >= 3.1 が必要であることに注意してください。