Boost logo

Boost Users :

Subject: [Boost-users] Boost.Hash and enums
From: Filip Konvička (filip.konvicka_at_[hidden])
Date: 2012-08-22 06:49:07


Hi,

In Boost 1.51, it looks to me like boost::hash_value no longer knows how
to handle enums anymore. Is the following the right way to tell it to
treat enums like ints?

#if (BOOST_VERSION >= 105100) // Boost 1.51.0+
namespace boost {
   /// Enable hashing of enums.
   template<typename E> size_t hash_value(
     E const e,
     typename std::enable_if<std::is_enum<E>::value, E>::type def =
       static_cast<E>(0))
   {
     return hash_value((int)e);
   }
}
#endif

Is enum hashing support going to be added to the library in the future?

Thanks,
Filip


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net