From bbf42659de5127e44edaac890b1c7d955e43ef74 Mon Sep 17 00:00:00 2001 From: Redstone1024 <2824517378@qq.com> Date: Sun, 3 Nov 2024 11:06:42 +0800 Subject: [PATCH] fix(templates): fix TOptional::operator* compilation error --- Redcraft.Utility/Source/Public/Templates/Optional.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Redcraft.Utility/Source/Public/Templates/Optional.h b/Redcraft.Utility/Source/Public/Templates/Optional.h index ae27998..4aad94e 100644 --- a/Redcraft.Utility/Source/Public/Templates/Optional.h +++ b/Redcraft.Utility/Source/Public/Templates/Optional.h @@ -314,16 +314,16 @@ public: NODISCARD FORCEINLINE constexpr const T& GetValue() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } NODISCARD FORCEINLINE constexpr const T&& GetValue() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } + /** @return The contained object. */ + NODISCARD FORCEINLINE constexpr T& operator*() & { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast< T*>(&Value); } + NODISCARD FORCEINLINE constexpr T&& operator*() && { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast< T*>(&Value)); } + NODISCARD FORCEINLINE constexpr const T& operator*() const& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return *reinterpret_cast(&Value); } + NODISCARD FORCEINLINE constexpr const T&& operator*() const&& { checkf(IsValid(), TEXT("It is an error to call GetValue() on an unset TOptional. Please either check IsValid() or use Get(DefaultValue) instead.")); return MoveTemp(*reinterpret_cast(&Value)); } + /** @return The pointer to the contained object. */ NODISCARD FORCEINLINE constexpr const T* operator->() const { return &GetValue(); } NODISCARD FORCEINLINE constexpr T* operator->() { return &GetValue(); } - /** @return The contained object. */ - NODISCARD FORCEINLINE constexpr T& operator*() & { return GetValue(); } - NODISCARD FORCEINLINE constexpr T&& operator*() && { return GetValue(); } - NODISCARD FORCEINLINE constexpr const T& operator*() const& { return GetValue(); } - NODISCARD FORCEINLINE constexpr const T&& operator*() const&& { return GetValue(); } - /** @return The contained object when IsValid() returns true, 'DefaultValue' otherwise. */ NODISCARD FORCEINLINE constexpr T& Get( T& DefaultValue) & { return IsValid() ? GetValue() : DefaultValue; } NODISCARD FORCEINLINE constexpr const T& Get(const T& DefaultValue) const& { return IsValid() ? GetValue() : DefaultValue; }