refactor(templates): refactor GetTypeHash into a member function

This commit is contained in:
2022-04-22 22:28:44 +08:00
parent 63b63ef0b4
commit 04d713cd93
6 changed files with 145 additions and 92 deletions

View File

@ -208,12 +208,6 @@ 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)
@ -225,6 +219,12 @@ public:
}
}
constexpr size_t GetTypeHash() const requires CHashable<OptionalType>
{
if (!IsValid()) return 2824517378;
return NAMESPACE_REDCRAFT::GetTypeHash(GetValue());
}
template <typename T> requires TIsMoveConstructible<OptionalType>::Value && TIsSwappable<OptionalType>::Value
constexpr void Swap(TOptional& InValue)
{