You can just specialize std::hash for your type:
namespace std { template <> struct hash<FullyQualified::LibEnum> { size_t operator ()(FullyQualified::LibEnum value) const { return static_cast<size_t>(value); } }; }
Alternatively, you can define the hash type, wherever you are, and simply provide it as an optional template argument when creating an instance of std::unordered_map<FooEnum> :
// Anywhere in your code prior to usage: struct myhash { std::size_t operator ()(LibEnum value) const { return static_cast<std::size_t>(value); } }; // Usage: std::unordered_map<LibEnum, T, myhash> some_hash;
None of the methods require changing the library.
Konrad Rudolph Feb 11 '13 at 14:27 2013-02-11 14:27
source share