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/Utility.h"
#include "Templates/TypeHash.h"
#include "Concepts/Comparable.h"
#include "TypeTraits/TypeTraits.h"
#include "Miscellaneous/AssertionMacros.h"
@ -189,6 +190,12 @@ public:
constexpr OptionalType& Get( OptionalType& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; }
constexpr const OptionalType& Get(const OptionalType& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; }
constexpr size_t GetTypeHash() const requires CHashable<OptionalType>
{
if (!IsValid()) return NAMESPACE_REDCRAFT::GetTypeHash(nullptr);
return NAMESPACE_REDCRAFT::GetTypeHash(GetValue());
}
constexpr void Reset()
{
if (bIsValid)