Change HashCompatible trait to a variable template
This commit is contained in:
parent
9329fc99d2
commit
b58f72315c
|
@ -61,12 +61,10 @@ struct Hash
|
||||||
// Traits specifying if two types have compatible hashing, that is,
|
// Traits specifying if two types have compatible hashing, that is,
|
||||||
// if lhs == rhs => hash_value(lhs) == hash_value(rhs)
|
// if lhs == rhs => hash_value(lhs) == hash_value(rhs)
|
||||||
template<typename Lhs, typename 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 T>
|
||||||
|
constexpr bool HashCompatible<T, T> = true;
|
||||||
template<typename Lhs, typename Rhs>
|
|
||||||
constexpr bool IsHashCompatible = HashCompatible<Lhs, Rhs>::value;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ struct HashMap
|
||||||
|
|
||||||
template<typename KeyType>
|
template<typename KeyType>
|
||||||
using EnableIfHashCompatible = std::enable_if_t<
|
using EnableIfHashCompatible = std::enable_if_t<
|
||||||
IsHashCompatible<Key, std::decay_t<KeyType>>
|
HashCompatible<Key, std::decay_t<KeyType>>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
template<typename KeyType, typename = EnableIfHashCompatible<KeyType>>
|
template<typename KeyType, typename = EnableIfHashCompatible<KeyType>>
|
||||||
|
|
|
@ -256,8 +256,8 @@ private:
|
||||||
|
|
||||||
static_assert(std::is_trivial<StringView>::value, "");
|
static_assert(std::is_trivial<StringView>::value, "");
|
||||||
|
|
||||||
template<> struct HashCompatible<String, StringView> : std::true_type {};
|
template<> constexpr bool HashCompatible<String, StringView> = true;
|
||||||
template<> struct HashCompatible<StringView, String> : std::true_type {};
|
template<> constexpr bool HashCompatible<StringView, String> = true;
|
||||||
|
|
||||||
inline String::String(StringView str) : String{str.begin(), str.length()} {}
|
inline String::String(StringView str) : String{str.begin(), str.length()} {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user