|
Boost : |
From: John Maddock (jz.maddock_at_[hidden])
Date: 2021-06-05 17:02:35
What's the best way to combine a hash value with a bool?
Specifically, if you're generating a hash value for a class which has a
one member a bool. Normally I would just boost::hash_combine all the
class members together, but doing that with a bool member leads to:
1>d:\data\boost\boost\boost\multiprecision\detail\hash.hpp(20,88):
warning C4805: '^': unsafe mix of type 'T' and type 'size_t' in operation
1>Â Â Â Â Â Â Â with
1>Â Â Â Â Â Â Â [
1>Â Â Â Â Â Â Â Â Â Â Â T=bool
1>Â Â Â Â Â Â Â ]
Followed by a long instantiation backtrace (this is from
Boost.Multiprecision).
Since there's only one bool in this class, I could just apply a unary ~Â
to the value when the bool is true, but obviously that wouldn't work for
classes with multiple bool's. Should we modify hash_combine for this
use case?
Cheers, John.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk