fix(templates): fix compile error in TReferenceWrapper constructor

This commit is contained in:
_Redstone_c_ 2022-11-15 22:15:10 +08:00
parent 391670adb7
commit f347132725
2 changed files with 15 additions and 11 deletions

View File

@ -18,7 +18,11 @@ public:
using Type = ReferencedType;
template <typename T = ReferencedType> requires CConvertibleTo<T, ReferencedType&>
constexpr TReferenceWrapper(T&& Object) : Pointer(AddressOf(Forward<T>(Object))) { }
constexpr TReferenceWrapper(T&& Object)
{
ReferencedType& Reference = Forward<T>(Object);
Pointer = AddressOf(Reference);
}
TReferenceWrapper(const TReferenceWrapper&) = default;

View File

@ -21,38 +21,38 @@ void AsConst(const T&& Ref) = delete;
template <typename T>
constexpr TRemoveReference<T>&& MoveTemp(T&& Obj)
{
typedef TRemoveReference<T> CastType;
return (CastType&&)Obj;
using CastType = TRemoveReference<T>;
return static_cast<CastType&&>(Obj);
}
template <typename T>
constexpr T CopyTemp(T& Val)
constexpr T CopyTemp(T& Obj)
{
return const_cast<const T&>(Val);
return const_cast<const T&>(Obj);
}
template <typename T>
constexpr T CopyTemp(const T& Val)
constexpr T CopyTemp(const T& Obj)
{
return Val;
return Obj;
}
template <typename T>
constexpr T&& CopyTemp(T&& Val)
constexpr T&& CopyTemp(T&& Obj)
{
return MoveTemp(Val);
return MoveTemp(Obj);
}
template <typename T>
constexpr T&& Forward(TRemoveReference<T>& Obj)
{
return (T&&)Obj;
return static_cast<T&&>(Obj);
}
template <typename T>
constexpr T&& Forward(TRemoveReference<T>&& Obj)
{
return (T&&)Obj;
return static_cast<T&&>(Obj);
}
template <typename T> requires requires(T& A, T& B) { A.Swap(B); }