[+] AuTuple hasher

[+] AuIsTuple
[+] AuIsTuple_v
This commit is contained in:
Reece Wilson 2023-03-13 16:25:13 +00:00
parent 389fc41351
commit 51691fdaca
3 changed files with 26 additions and 2 deletions

View File

@ -230,6 +230,20 @@ namespace AuHash
AuHashCode(AuGet<1>(pair));
}
};
template <class ...Ts>
struct hash<AuTuple<Ts...>>
{
constexpr AuUInt operator ()(const AuTuple<Ts...> &tuple) const
{
AuUInt uHashCode {};
AuTupleForEach(tuple, [&](auto & a /*c++14 poggurs*/)
{
uHashCode ^= AuHashCode(a);
});
return uHashCode;
}
};
}
template <class T>

View File

@ -40,8 +40,7 @@ template <class T>
using AuToIterator_t = typename T::iterator;
template <typename T>
static AuToIterator_t<T> AuToIterator(const T &a); // intended use case: screwing over nasty ass lines of `AuToIterator_t<decltype(muh member)>` or worse.
// example usage: `decltype(AuToIterator(myHashMap)) itr;`
static AuToIterator_t<T> AuToIterator(const T &a); // intended use case: `decltype(AuToIterator(myHashMap)) itr;`
template <typename T>
static AuToElementType_t<T> AuToElementType(const T &a);

View File

@ -36,6 +36,17 @@
#define AURORA_RUNTIME_APPLY std::apply
#endif
template<typename T>
struct AuIsTuple : AuFalseType
{ };
template<typename... Ts>
struct AuIsTuple<AuTuple<Ts...>> : AuTrueType
{ };
template <class T>
inline constexpr bool AuIsTuple_v = AuIsTuple<T>::type::value;
template <class... Args>
static auto AuMakePair(Args&&... args)
{