File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ BOOST_HANA_NAMESPACE_BEGIN
8080 }
8181 };
8282
83+ template <typename T>
84+ struct hash_integral_helper <T,
85+ typename std::enable_if<std::is_enum<T>::value>::type
86+ > {
87+ template <typename X>
88+ static constexpr auto apply (X const &) {
89+ return hana::type_c<X>;
90+ }
91+ };
92+
8393 template <>
8494 struct hash_integral_helper <bool > {
8595 template <typename X>
Original file line number Diff line number Diff line change @@ -107,4 +107,26 @@ int main() {
107107 hana::type_c<hana::false_>
108108 ));
109109 }
110+
111+ // Enumeration constants should hash to themselves
112+ {
113+ enum enum_1 { zero };
114+ enum class enum_2 { zero };
115+ enum class enum_3 : unsigned { zero };
116+
117+ BOOST_HANA_CONSTANT_ASSERT (hana::equal (
118+ hana::hash (hana::integral_c<enum_1, zero>),
119+ hana::type_c<hana::integral_constant<enum_1, zero>>
120+ ));
121+
122+ BOOST_HANA_CONSTANT_ASSERT (hana::equal (
123+ hana::hash (hana::integral_c<enum_2, enum_2::zero>),
124+ hana::type_c<hana::integral_constant<enum_2, enum_2::zero>>
125+ ));
126+
127+ BOOST_HANA_CONSTANT_ASSERT (hana::equal (
128+ hana::hash (hana::integral_c<enum_3, enum_3::zero>),
129+ hana::type_c<hana::integral_constant<enum_3, enum_3::zero>>
130+ ));
131+ }
110132}
You can’t perform that action at this time.
0 commit comments