diff --git a/enum.h b/enum.h index 6618a7a..c3eee79 100644 --- a/enum.h +++ b/enum.h @@ -949,16 +949,6 @@ operator >>(std::basic_istream& stream, Enum &value) \ stream.setstate(std::basic_istream::failbit); \ \ return stream; \ -} \ - \ -namespace std { \ -template <> struct hash \ -{ \ - size_t operator()(const Enum &x) const \ - { \ - return std::hash()(x._to_index()); \ - } \ -}; \ } @@ -1293,4 +1283,17 @@ BETTER_ENUMS_CONSTEXPR_ map make_map(T (*f)(Enum)) } +#ifndef BETTER_ENUMS_DECLARE_STD_HASH +#define BETTER_ENUMS_DECLARE_STD_HASH(type) \ + namespace std { \ + template <> struct hash \ + { \ + size_t operator()(const type &x) const \ + { \ + return std::hash()(x._to_index()); \ + } \ + }; \ + } +#endif + #endif // #ifndef BETTER_ENUMS_ENUM_H