Another approach to specialize the hash easier.

This commit is contained in:
Sven Scharmentke 2019-07-11 08:57:01 +02:00
parent 8a118fc294
commit 8aa4bffb22

23
enum.h
View File

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