Index: mojo/public/cpp/bindings/lib/bindings_internal.h |
diff --git a/mojo/public/cpp/bindings/lib/bindings_internal.h b/mojo/public/cpp/bindings/lib/bindings_internal.h |
index b32cf694b9e62ed5b47d8e4c382643b74f108eec..b37d87273f7b7aab715177084a3962731300250c 100644 |
--- a/mojo/public/cpp/bindings/lib/bindings_internal.h |
+++ b/mojo/public/cpp/bindings/lib/bindings_internal.h |
@@ -7,6 +7,9 @@ |
#include <stdint.h> |
+#include <functional> |
+ |
+#include "base/template_util.h" |
#include "mojo/public/cpp/bindings/interface_id.h" |
#include "mojo/public/cpp/bindings/lib/template_util.h" |
#include "mojo/public/cpp/system/core.h" |
@@ -315,6 +318,16 @@ struct BelongsTo { |
static_cast<uint32_t>(MojomTypeTraits<T>::category & categories) != 0; |
}; |
+template <typename T> |
+struct EnumHashImpl { |
+ static_assert(std::is_enum<T>::value, "Incorrect hash function."); |
+ |
+ size_t operator()(T input) const { |
+ using UnderlyingType = typename base::underlying_type<T>::type; |
+ return std::hash<UnderlyingType>()(static_cast<UnderlyingType>(input)); |
+ } |
+}; |
+ |
} // namespace internal |
} // namespace mojo |