feat(templates): add type hash support and the corresponding testing

This commit is contained in:
2022-03-31 16:40:31 +08:00
parent c4c205e35b
commit 54ab72224f
8 changed files with 121 additions and 7 deletions

View File

@ -2,6 +2,7 @@
#include "CoreTypes.h"
#include "Templates/Invoke.h"
#include "Templates/TypeHash.h"
#include "Templates/Utility.h"
#include "TypeTraits/TypeTraits.h"
#include "Miscellaneous/AssertionMacros.h"
@ -418,6 +419,12 @@ struct TVariant
return R(NAMESPACE_PRIVATE::TVariantVisitHelper<R, F, Types...>::VisitConstRValueFuncs[GetIndex()](Forward<F>(Func), &Value));
}
constexpr size_t GetTypeHash() const requires (true && ... && CHashable<Types>)
{
if (!IsValid()) return NAMESPACE_REDCRAFT::GetTypeHash(nullptr);
return Visit([](auto&& A) { return NAMESPACE_REDCRAFT::GetTypeHash(A); });
}
constexpr void Reset()
{
if (GetIndex() == INDEX_NONE) return;