fix(templates): fix TOptional::operator* compilation error

This commit is contained in:
Redstone1024 2024-11-03 11:06:42 +08:00
parent 8507ae32e3
commit bbf42659de

View File

@ -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<const T*>(&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<const T*>(&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<const 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 MoveTemp(*reinterpret_cast<const T*>(&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; }