[+] AU_DEFINE_HASHCODE_VA, define AU_DEFINE_EQUALS_VA

[*] Missing AuTryInsert pointer helpers
[*] Missing const specifier
This commit is contained in:
Reece Wilson 2022-03-28 17:51:20 +01:00
parent 55ff37731f
commit 10becf180c
3 changed files with 35 additions and 3 deletions

View File

@ -228,4 +228,24 @@ inline thisType(AU_FOR_EACH_FIRST(AU_EMIT_CTOR_MOV, AU_EMIT_CTOR_MOV_SECOND, AU_
///
#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
#define AU_DEFINE_CTOR_VA(thisType, args) AU_DEFINE_CTOR_CPY_VA(thisType, args) AU_DEFINE_CTOR_MOV_VA(thisType, args)
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_A(name) this->name == ref.name
/// @hideinitializer
#define AU_DEFINE_EQUALS_VA_B(name) && AU_DEFINE_EQUALS_VA_A(name)
///
#define AU_DEFINE_EQUALS_VA(thisType, args) bool operator==(const thisType & ref) const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_VA_A, AU_DEFINE_EQUALS_VA_B, AU_STRIP_BRACKETS(args)) ; }
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_A(name) AuHashCode(this->name)
/// @hideinitializer
#define AU_DEFINE_EQUALS_HASHCODE_B(name) ^ AU_DEFINE_EQUALS_HASHCODE_A(name)
///
#define AU_DEFINE_HASHCODE_VA(thisType, args) AuUInt HashCode() const noexcept { return AU_FOR_EACH_FIRST(AU_DEFINE_EQUALS_HASHCODE_A, AU_DEFINE_EQUALS_HASHCODE_B, AU_STRIP_BRACKETS(args)) ; }

View File

@ -474,6 +474,18 @@ inline bool AuTryInsert(Container &container, const Value &value)
}
}
template <class Map, class Key, class Value>
inline bool AuTryInsert(const Map *map, Key &&key, Value &&value)
{
return AuTryInsert(*map, AuMove(key), AuMove(value));
}
template <class Map, class Key, class Value>
inline bool AuTryInsert(const Map *map, const Key &key, Value &&value)
{
return AuTryInsert(*map, AuReference(key), AuMove(value));
}
template <class Map, class Value>
inline bool AuTryInsert(const Map *map, Value &&value)
{

View File

@ -135,9 +135,9 @@ struct AuEnableHashCodeOnData
AuUInt HashCode() const
{
#if defined(AURORA_IS_32BIT)
return AuFnv1a32Runtime(AuStaticCast<T>(this), sizeof(T));
return AuFnv1a32Runtime(AuStaticCast<AuAddConst_t<T>>(this), sizeof(T));
#else
return AuFnv1a64Runtime(AuStaticCast<T>(this), sizeof(T));
return AuFnv1a64Runtime(AuStaticCast<AuAddConst_t<T>>(this), sizeof(T));
#endif
}
};