Boost logo

Boost :

Subject: [boost] boost::hash - different values for the same input?
From: trafdev (trafdev_at_[hidden])
Date: 2015-12-09 15:13:51


As per hash_range docs

"This hash function is not intended for general use, and isn't
guaranteed to be equal during separate runs of a program - so please
don't use it for any persistent storage or communication."

As per code
( it
uses hash_combine_impl which doesn't use any random, process_id etc
values which might change during new process launches.

At the same time, in an example describing container usage in the shared
boost::hash is being used:

typedef boost::unordered_map
       < KeyType , MappedType
       , boost::hash<KeyType> ,std::equal_to<KeyType>
       , ShmemAllocator>

My question is: is it safe to use boost::hash in a shared (persistent)
storage or it's safe only for a particular (non-pointer) types?

In this case, boost::hash docs should be changed to mention this
exceptions, because otherwise no one could use boost::hash in a shared
memory containers.

Boost list run by bdawes at, gregod at, cpdaniel at, john at