user1824407
user1824407

Reputation: 4559

What is the purpose of std::hash and/or boost::hash ?

Why providing an hash function without specifing any implementation of reference and also without specifying the algorithm of reference ( md5, sha256, etc etc ) ?

Also there are similar features for data structures such as the C++ standard-compliant std::unordered_map/set/multimap/multiset::hash_function.

So what i don't get is:

Upvotes: 0

Views: 1918

Answers (1)

K-ballo
K-ballo

Reputation: 81349

Why providing such undocumented methods

They are not undocumented.

The implementation details are fundamental for a right use of the hash functions, from a programmer standpoint what is the purpose of these functions

The implementation is unspecified, they are just supposed to be used together with unordered containers. They should be as good a hash function as possible, to effectively distribute elements into buckets. Anything else is unspecified.

Note that user is expected to provide these if using unordered containers with user defined types.

This function can be linked to a specific algorithm ?

Why not?

Upvotes: 3

Related Questions