It seems intuitive that one should be able to use sets of sets, and indeed std::set
is designed to support such use by default (since lexicographical ordering is implemented by default.) Similarly, it seems reasonable to expect the same feature of boost::unordered_set
. Is there a good reason why boost doesn't implement a generalized hash function for boost::unordered_set
by default, something like:
// DEFINE A HASH FUNCTION FOR A HASH-SET THAT COMBINES THE HASH VALUES
// OF THE ELEMENTS OF THAT SET
namespace boost {
template<typename T>
size_t hash_value(const boost::unordered_set<T> & set) {
typename boost::unordered_set<T>::const_iterator it, itend;
size_t seed = 0;
for ( it = set.begin(), itend = set.end(); it != itend; it++ ){
boost::hash_combine(seed,boost::hash_value(*it));
}
return seed;
}
}