From b58f72315cbf7ee8921659dd129fd2f6a221bcfc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 14 Aug 2017 11:54:38 +0700 Subject: [PATCH] Change HashCompatible trait to a variable template --- src/hash.hh | 8 +++----- src/hash_map.hh | 2 +- src/string.hh | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/hash.hh b/src/hash.hh index 35e89e84..8e5e319c 100644 --- a/src/hash.hh +++ b/src/hash.hh @@ -61,12 +61,10 @@ struct Hash // Traits specifying if two types have compatible hashing, that is, // if lhs == rhs => hash_value(lhs) == hash_value(rhs) template -struct HashCompatible : std::false_type {}; +constexpr bool HashCompatible = false; -template struct HashCompatible : std::true_type {}; - -template -constexpr bool IsHashCompatible = HashCompatible::value; +template +constexpr bool HashCompatible = true; } diff --git a/src/hash_map.hh b/src/hash_map.hh index 4263b195..89c97b00 100644 --- a/src/hash_map.hh +++ b/src/hash_map.hh @@ -156,7 +156,7 @@ struct HashMap template using EnableIfHashCompatible = std::enable_if_t< - IsHashCompatible> + HashCompatible> >; template> diff --git a/src/string.hh b/src/string.hh index bb026869..98d78ff6 100644 --- a/src/string.hh +++ b/src/string.hh @@ -256,8 +256,8 @@ private: static_assert(std::is_trivial::value, ""); -template<> struct HashCompatible : std::true_type {}; -template<> struct HashCompatible : std::true_type {}; +template<> constexpr bool HashCompatible = true; +template<> constexpr bool HashCompatible = true; inline String::String(StringView str) : String{str.begin(), str.length()} {}