refactor(templates): do not allow TReferenceWrapper to rebind a new object

This commit is contained in:
_Redstone_c_ 2022-12-13 22:11:10 +08:00
parent ac9e0d38a6
commit ca67769796

View File

@ -25,20 +25,18 @@ public:
} }
FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper&) = default; FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper&) = default;
FORCEINLINE constexpr TReferenceWrapper(TReferenceWrapper&&) = default;
template <typename T = ReferencedType> requires (CConvertibleTo<T&, ReferencedType&>) template <typename T = ReferencedType> requires (CConvertibleTo<T&, ReferencedType&>)
FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper<T>& InValue) FORCEINLINE constexpr TReferenceWrapper(const TReferenceWrapper<T>& InValue)
: Pointer(InValue.Pointer) : Pointer(InValue.Pointer)
{ } { }
FORCEINLINE constexpr TReferenceWrapper& operator=(const TReferenceWrapper&) = default; template <typename T = ReferencedType> requires (CAssignableFrom<ReferencedType&, T&&>)
FORCEINLINE constexpr TReferenceWrapper& operator=(T&& Object) { Get() = Forward<T>(Object); return *this; }
template <typename T = ReferencedType> requires (CConvertibleTo<T&, ReferencedType&>)
FORCEINLINE constexpr TReferenceWrapper& operator=(const TReferenceWrapper<T>& InValue) FORCEINLINE constexpr TReferenceWrapper& operator=(const TReferenceWrapper&) = delete;
{ FORCEINLINE constexpr TReferenceWrapper& operator=(TReferenceWrapper&&) = delete;
Pointer = InValue.Pointer;
return *this;
}
FORCEINLINE constexpr operator ReferencedType&() const { return *Pointer; } FORCEINLINE constexpr operator ReferencedType&() const { return *Pointer; }
FORCEINLINE constexpr ReferencedType& Get() const { return *Pointer; } FORCEINLINE constexpr ReferencedType& Get() const { return *Pointer; }