I'm wondering if there's some efficient way to hash std::bitset or boost::dynamic_bitset<> for Boost's unordered containers?
I'm currently converting std::bitset or boost::dynamic_bitset<> to std::string first before hashing them, but it seems this is going to be slow.
Is there some better way?
The C++11 requires standard library to have
std::hash<std::bitset>specialized. IOW it should have hash already.For boost you should use config:
#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDSthen thedynamic_bitset::m_bitsmember becomes public and you can make hash on it.