diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-08-14 11:54:38 +0700 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-08-14 11:54:38 +0700 |
| commit | b58f72315cbf7ee8921659dd129fd2f6a221bcfc (patch) | |
| tree | d2c54fff8e89040dab71558ebfc8d7b5812c1ddb /src | |
| parent | 9329fc99d26fd567ffc13aaaab83237ebec9a8ba (diff) | |
Change HashCompatible trait to a variable template
Diffstat (limited to 'src')
| -rw-r--r-- | src/hash.hh | 8 | ||||
| -rw-r--r-- | src/hash_map.hh | 2 | ||||
| -rw-r--r-- | 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<typename Lhs, typename Rhs> -struct HashCompatible : std::false_type {}; +constexpr bool HashCompatible = false; -template<typename T> struct HashCompatible<T, T> : std::true_type {}; - -template<typename Lhs, typename Rhs> -constexpr bool IsHashCompatible = HashCompatible<Lhs, Rhs>::value; +template<typename T> +constexpr bool HashCompatible<T, T> = 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<typename KeyType> using EnableIfHashCompatible = std::enable_if_t< - IsHashCompatible<Key, std::decay_t<KeyType>> + HashCompatible<Key, std::decay_t<KeyType>> >; template<typename KeyType, typename = EnableIfHashCompatible<KeyType>> 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<StringView>::value, ""); -template<> struct HashCompatible<String, StringView> : std::true_type {}; -template<> struct HashCompatible<StringView, String> : std::true_type {}; +template<> constexpr bool HashCompatible<String, StringView> = true; +template<> constexpr bool HashCompatible<StringView, String> = true; inline String::String(StringView str) : String{str.begin(), str.length()} {} |
