make enum hashable

This commit is contained in:
Jacob Dufault 2017-03-24 18:01:41 -07:00
parent 539c779606
commit 17c3af4d40
3 changed files with 12 additions and 3 deletions

View File

@ -29,6 +29,7 @@ enum class lsMethodId : int {
CodeLensResolve, CodeLensResolve,
WorkspaceSymbol, WorkspaceSymbol,
}; };
MAKE_ENUM_HASHABLE(lsMethodId);
template<typename TVisitor> template<typename TVisitor>
void Reflect(TVisitor& visitor, lsMethodId& value) { void Reflect(TVisitor& visitor, lsMethodId& value) {
@ -1269,7 +1270,6 @@ struct In_InitializeRequest : public InRequestMessage {
In_InitializeRequest(optional<RequestId> id, Reader& reader) In_InitializeRequest(optional<RequestId> id, Reader& reader)
: InRequestMessage(kMethod, id, reader) { : InRequestMessage(kMethod, id, reader) {
auto type = reader.GetType();
Reflect(reader, params); Reflect(reader, params);
std::cerr << "done" << std::endl; std::cerr << "done" << std::endl;
} }

View File

@ -50,3 +50,12 @@ inline void hash_combine(std::size_t& seed, const T& v, Rest... rest) {
}\ }\
};\ };\
} }
#define MAKE_ENUM_HASHABLE(type) \
namespace std {\
template<> struct hash<type> {\
std::size_t operator()(const type &t) const {\
return hash<int>()(static_cast<int>(t));\
}\
};\
}