[转载]标准库的字符串哈希算法

时间:2021-04-16 16:45:05
// http://en.cppreference.com/w/cpp/string/basic_string/hash

#include <iostream>
#include <string>
#include <functional>

int main()
{
    std::string s = "abc";
    std::hash<std::string> hash_fn;

    size_t hash = hash_fn(s);

    std::cout << hash << '\n';
}
/* Example: a 4993892634952068459 b 10838281452030117757 ab 5498234120169091963 abc 3663726644998027833 */