template<Bool ALLOW_UNDEFINED, EQUALITY EQ = EQUALITY::SHALLOW, typename OPERATOR_RANK = OverloadRank5>
class maxon::CompareTemplate< ALLOW_UNDEFINED, EQ, OPERATOR_RANK >
This class implements default compare and hash functions. They are used at various places such as DataType or HashMap. The class defines IsEqual and GetHashCode for the following cases:
- arithmetic and enumeration values
- pointers (where different pointers are assumed to be different keys, so only the address is considered, not the content)
- strong non-copy-on-write references (using their pointer)
- objects whose type has a GetHashCode member function and which can be compared with == The class defines Compare for the following cases:
- arithmetic values
For any other case you can specialize the template functions of DefaultCompare, or you have to define your own comparison and hash function class, see CStringCompare for the case of C-strings.
Note that hashes are not meant to be stored in files as they are only valid during runtime. The datatype for hashes is UInt which is variable in width.
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE COMPARERESULT | Compare (const T1 &a, const T2 &b) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (UInt32 h) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (UInt64 h) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Bool i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Char i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (UChar i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Int16 i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (UInt16 i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Int32 h) |
|
static HashInt | GetHashCode (Utf16Char i) |
|
static HashInt | GetHashCode (Utf32Char i) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Int64 h) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Float32 h) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (Float64 h) |
|
template<typename T > |
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (const T *key) |
|
template<typename T > |
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (T *key) |
|
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (std::nullptr_t) |
|
template<typename E > |
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (const maxon::details::EnumWrapper< E > &key) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCode (const K &key) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE UniqueHash | GetUniqueHashCode (const K &key) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | IsEqual (const T1 &a, const T2 &b) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | LessThan (const T1 &a, const T2 &b) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | LessThanOrEqual (const T1 &a, const T2 &b) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE const COMPARERESULT & | CompareHelper (const T1 &a, const T2 &b, OverloadRank0) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | CompareHelper (const T1 &a, const T2 &b, OverloadRank1) -> decltype((a< b) ? COMPARERESULT::LESS :COMPARERESULT::EQUAL) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | CompareHelper (const T1 &a, const T2 &b, OverloadRank2) -> decltype(a.Compare(b)) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE SFINAEHelper< COMPARERESULT, typename T1::PartiallyOrdered >::type | CompareHelper (const T1 &a, const T2 &b, OverloadRank3) |
|
template<typename... T> |
static HashInt | GetCombinedHashCode (const T &... values) |
|
template<typename... T> |
static UniqueHash | GetCombinedUniqueHash (const T &... values) |
|
|
template<typename K1 , typename K2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | IsEqualHelper (const K1 &a, const K2 &b, OverloadRank0) |
|
static Bool | DecltypeIsEqualHelper (COMPARERESULT) |
|
template<typename K1 , typename K2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | IsEqualHelper (const K1 &a, const K2 &b, OverloadRank2) -> decltype(DecltypeIsEqualHelper(a.Compare(b))) |
|
template<typename K1 , typename K2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | IsEqualHelper (const K1 &a, const K2 &b, OverloadRank3) -> decltype(a.IsEqual(b)) |
|
template<typename K1 , typename K2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | IsEqualHelper (const K1 &a, const K2 &b, OverloadRank4) -> decltype(a.IsEqual(b, EQ)) |
|
template<typename K1 , typename K2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | IsEqualHelper (const K1 &a, const K2 &b, OPERATOR_RANK) -> decltype(a==b) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | LessThanOrEqualHelper (const T1 &a, const T2 &b, OverloadRank0) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | LessThanOrEqualHelper (const T1 &a, const T2 &b, OverloadRank1) -> decltype(a.LessThan(b)) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | LessThanOrEqualHelper (const T1 &a, const T2 &b, OverloadRank2) -> decltype(a.LessThanOrEqual(b)) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | LessThanOrEqualHelper (const T1 &a, const T2 &b, OverloadRank3) -> decltype(a<=b) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE Bool | LessThanHelper (const T1 &a, const T2 &b, OverloadRank0) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | LessThanHelper (const T1 &a, const T2 &b, OverloadRank1) -> decltype(a.LessThan(b)) |
|
template<typename T1 , typename T2 > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | LessThanHelper (const T1 &a, const T2 &b, OverloadRank2) -> decltype(a< b) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE HashInt | GetHashCodeHelper (const K &key, OverloadRank0) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | GetHashCodeHelper (const K &key, OverloadRank1) -> decltype(key.GetHashCode()) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< STD_IS_REPLACEMENT(enum, K), HashInt >::type | GetHashCodeHelper (const K &key, OverloadRank2) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE UniqueHash | GetUniqueHashCodeHelper (const K &key, OverloadRank0) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< IsTriviallyHashable< K >::value, UniqueHash >::type | GetUniqueHashCodeHelper (const K &key, OverloadRank1) |
|
template<typename K > |
static MAXON_ATTRIBUTE_FORCE_INLINE auto | GetUniqueHashCodeHelper (const K &key, OverloadRank2) -> decltype(key.GetUniqueHashCode()) |
|