[+] Strict AuMove/Forward in casts

[*] Formatting
This commit is contained in:
Reece Wilson 2022-03-25 22:46:46 +00:00
parent 5b91d0c30e
commit ed45ac75c1
3 changed files with 25 additions and 24 deletions

View File

@ -32,7 +32,7 @@ namespace Aurora::Memory
inline IPtrNoOpGet gNoop;
}
template<class TType_t, class Base_t>
template <class TType_t, class Base_t>
struct ExSharedPtr : Base_t
#if !defined(_AURORA_NULLEXPT_ENABLE_UB) && !defined(_AURORA_NULLEXPT_BRANCH)
, private _detail::IPtrGet
@ -71,7 +71,7 @@ namespace Aurora::Memory
#endif
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in) : Base_t(in.BasePointerType(), static_cast<T_t *>(in.get()))
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -79,7 +79,7 @@ namespace Aurora::Memory
#endif
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in) : Base_t(in.BasePointerType(), static_cast<T_t *>(in.get()))
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -87,7 +87,7 @@ namespace Aurora::Memory
#endif
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr(ExSharedPtr<T_t, B_t> &&in, element_type *ptr) : Base_t(in.BasePointerType(), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -102,7 +102,7 @@ namespace Aurora::Memory
#endif
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr(const ExSharedPtr<T_t, B_t> &in, element_type *ptr) : Base_t(in.BasePointerType(), ptr)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -124,7 +124,7 @@ namespace Aurora::Memory
#endif
}
template<class Y = element_type, class Deleter_t, class Alloc_t>
template <class Y = element_type, class Deleter_t, class Alloc_t>
ExSharedPtr(Y *in, Deleter_t del, Alloc_t alloc) : Base_t(in, del, alloc)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -132,7 +132,7 @@ namespace Aurora::Memory
#endif
}
template<class Y = element_type, class Deleter_t>
template <class Y = element_type, class Deleter_t>
ExSharedPtr(Y *in, Deleter_t del) : Base_t(in, del)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -140,7 +140,7 @@ namespace Aurora::Memory
#endif
}
template< class Y, class Deleter >
template < class Y, class Deleter >
ExSharedPtr(AURORA_RUNTIME_AU_UNIQUE_PTR<Y, Deleter> &&r) : Base_t(r)
{
#if !defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -149,7 +149,7 @@ namespace Aurora::Memory
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
void swap(ExSharedPtr<T_t, B_t> &in)
{
Base_t::swap(in.BasePointerType());
@ -214,7 +214,7 @@ namespace Aurora::Memory
return *this;
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr &operator =(ExSharedPtr<T_t, B_t> &&in) noexcept
{
Base_t::operator=(AuMove(in.BasePointerType()));
@ -245,7 +245,7 @@ namespace Aurora::Memory
return *this;
}
template<typename T_t, typename B_t>
template <class T_t, typename B_t>
ExSharedPtr &operator =(const ExSharedPtr<T_t, B_t> &in) noexcept
{
Base_t::operator=(in.BasePointerType());
@ -256,13 +256,13 @@ namespace Aurora::Memory
return *this;
}
template<typename TType2_t = TType_t>
template <class TType2_t = TType_t>
TType2_t &operator*() const
{
return *operator->();
}
template<typename TType2_t = TType_t>
template <class TType2_t = TType_t>
TType2_t *operator->() const
{
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -275,13 +275,13 @@ namespace Aurora::Memory
#endif
}
template<typename TType2_t = TType_t>
template <class TType2_t = TType_t>
TType2_t &operator*()
{
return *operator->();
}
template<typename TType2_t = TType_t>
template <class TType2_t = TType_t>
TType2_t *operator->()
{
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
@ -300,13 +300,13 @@ namespace Aurora::Memory
}
#define ADD_OPERATOR(op) \
template<class T > \
template <class T > \
bool operator op(const T &rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
} \
\
template< class T > \
template < class T > \
bool operator op(std::nullptr_t rhs) noexcept \
{ \
return static_cast<Base_t &>(*this) op(rhs); \
@ -316,7 +316,7 @@ namespace Aurora::Memory
ADD_OPERATOR(==)
ADD_OPERATOR(!=)
#if defined(AU_LANG_CPP_20)
template< class T >
template < class T >
std::strong_ordering operator<=>(const T &rhs) noexcept
{
return Base_t::operator<=>(rhs);
@ -384,7 +384,7 @@ namespace Aurora::Memory
#endif
};
template<class TType_t, class Base_t>
template <class TType_t, class Base_t>
struct ExSharedFromThis : Base_t
{
ExSharedPtr<TType_t, AURORA_RUNTIME_AU_SHARED_PTR<TType_t>> SharedFromThis()

View File

@ -28,13 +28,13 @@ static constexpr AuConditional_t<AuIsPointer_v<T>, T, T *> AuStaticCast(Z *other
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &> AuStaticCast(Z &other)
{
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(other);
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(AuForward(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &&> AuStaticCast(Z &&other)
{
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(other);
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(AuMove(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsPointer_v<T> && !AuIsPointer_v<Z>)>
@ -52,13 +52,13 @@ static constexpr AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *other)
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &> AuConstCast(Z &other)
{
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(other);
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(AuForward(other));
}
template <class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate_v<AURORA_RUNTIME_AU_SHARED_PTR, Z>)>
static constexpr AuConditional_t<AuIsReference_v<T>, T, T &&> AuConstCast(Z &&other)
{
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(other);
return const_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(AuMove(other));
}
template <class T, class Z>

View File

@ -171,6 +171,7 @@ namespace __audetail
template <class Invokable, typename... Ts>
static auto AuTupleTransform(const AuTuple<Ts...> &tuple, const Invokable &translate)
{
return __audetail::AuTupleTransformImpl(translate, tuple,
return __audetail::AuTupleTransformImpl(translate,
tuple,
AuMakeIndexSequence<sizeof...(Ts)>());
}