mirror of
https://github.com/aantron/better-enums.git
synced 2025-12-08 01:36:44 +08:00
Support hashing.
This enabled hashing so that unordered_map are supported.
This commit is contained in:
parent
8a0d376b53
commit
8a118fc294
10
enum.h
10
enum.h
@ -949,6 +949,16 @@ 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()); \
|
||||
} \
|
||||
}; \
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user