refactor(templates): remove the GetData function from the non-container class

This commit is contained in:
2022-04-24 22:42:40 +08:00
parent b3a97cfe21
commit c2eca8df1e
5 changed files with 85 additions and 129 deletions

View File

@ -338,9 +338,6 @@ struct TVariant
template <size_t I> constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == I : false; }
template <typename T> constexpr bool HoldsAlternative() const { return IsValid() ? GetIndex() == TAlternativeIndex<T>::Value : false; }
constexpr void* GetData() { return &Value; }
constexpr const void* GetData() const { return &Value; }
template <size_t I> requires (I < AlternativeSize) constexpr typename TAlternativeType<I>::Type& GetValue() & { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return *reinterpret_cast< TAlternativeType<I>::Type*>(&Value); }
template <size_t I> requires (I < AlternativeSize) constexpr typename TAlternativeType<I>::Type&& GetValue() && { checkf(HoldsAlternative<I>(), TEXT("It is an error to call GetValue() on an wrong TVariant. Please either check HoldsAlternative() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< TAlternativeType<I>::Type*>(&Value)); }
@ -456,7 +453,7 @@ struct TVariant
if (GetIndex() == InValue.GetIndex())
{
FHelper::SwapFuncs[GetIndex()](GetData(), InValue.GetData());
FHelper::SwapFuncs[GetIndex()](&Value, &InValue.Value);
return;
}