The following code snippet can do hash value on a string object. I would like to get hash value a binary string (a pointer and length). I know I can form a string object with pointer and length, but there is extra overhead to form a string only for that. Wonder if it's possible to use the std hash function with two parameters: pointer and length.
Thanks.
#include <iostream>
#include <functional>
#include <string>
int main()
{
std::string str = "Meet the new boss...";
std::hash<std::string> hash_fn;
std::size_t str_hash = hash_fn(str);
std::cout << str_hash << '\n';
}