diff --git a/include/boost/hana/hash.hpp b/include/boost/hana/hash.hpp index 538ef36eca..0a42eca176 100644 --- a/include/boost/hana/hash.hpp +++ b/include/boost/hana/hash.hpp @@ -80,6 +80,16 @@ BOOST_HANA_NAMESPACE_BEGIN } }; + template + struct hash_integral_helper::value>::type + > { + template + static constexpr auto apply(X const&) { + return hana::type_c; + } + }; + template <> struct hash_integral_helper { template diff --git a/test/integral_constant/hash.cpp b/test/integral_constant/hash.cpp index 59cf070572..c628966d65 100644 --- a/test/integral_constant/hash.cpp +++ b/test/integral_constant/hash.cpp @@ -107,4 +107,26 @@ int main() { hana::type_c )); } + + // Enumeration constants should hash to themselves + { + enum enum_1 { zero }; + enum class enum_2 { zero }; + enum class enum_3 : unsigned { zero }; + + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + } }