From 17c3af4d4020a449418ff0a64f6cdcf2a6c8b891 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 24 Mar 2017 18:01:41 -0700 Subject: [PATCH] make enum hashable --- language_server_api.h | 2 +- src/typed_bidi_message_queue.h | 2 +- utils.h | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/language_server_api.h b/language_server_api.h index 3f9aea2e..abed82e3 100644 --- a/language_server_api.h +++ b/language_server_api.h @@ -29,6 +29,7 @@ enum class lsMethodId : int { CodeLensResolve, WorkspaceSymbol, }; +MAKE_ENUM_HASHABLE(lsMethodId); template void Reflect(TVisitor& visitor, lsMethodId& value) { @@ -1269,7 +1270,6 @@ struct In_InitializeRequest : public InRequestMessage { In_InitializeRequest(optional id, Reader& reader) : InRequestMessage(kMethod, id, reader) { - auto type = reader.GetType(); Reflect(reader, params); std::cerr << "done" << std::endl; } diff --git a/src/typed_bidi_message_queue.h b/src/typed_bidi_message_queue.h index bceedc4d..466833c0 100644 --- a/src/typed_bidi_message_queue.h +++ b/src/typed_bidi_message_queue.h @@ -105,4 +105,4 @@ struct TypedBidiMessageQueue { std::unordered_map serializers_; std::unordered_map deserializers_; -}; \ No newline at end of file +}; diff --git a/utils.h b/utils.h index ff13e6ba..60f79fa7 100644 --- a/utils.h +++ b/utils.h @@ -49,4 +49,13 @@ inline void hash_combine(std::size_t& seed, const T& v, Rest... rest) { return ret;\ }\ };\ - } \ No newline at end of file + } + +#define MAKE_ENUM_HASHABLE(type) \ + namespace std {\ + template<> struct hash {\ + std::size_t operator()(const type &t) const {\ + return hash()(static_cast(t));\ + }\ + };\ + }