[*] Work out additional kinks in casts
This commit is contained in:
parent
e4ed0856de
commit
216587195e
@ -8,65 +8,59 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
AuConditional_t<AuIsPointer_v<T>, T, T *> AuStaticCast(Z *other)
|
static AuSPtr<T> AuStaticCast(const AuSPtr<Z> &other)
|
||||||
{
|
|
||||||
return static_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class Z>
|
|
||||||
AuConditional_t<AuIsReference_v<T>, T, T &> AuStaticCast(Z &other)
|
|
||||||
{
|
|
||||||
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class Z>
|
|
||||||
AuConditional_t<AuIsReference_v<T>, T, T &&> AuStaticCast(Z &&other)
|
|
||||||
{
|
|
||||||
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, class Z>
|
|
||||||
T AuStaticCast(Z other)
|
|
||||||
{
|
|
||||||
return static_cast<T>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class Z>
|
|
||||||
AuSPtr<T> AuStaticCast(const AuSPtr<Z> &other)
|
|
||||||
{
|
{
|
||||||
return AuSPtr<T>(other, static_cast<T *>(other.get()));
|
return AuSPtr<T>(other, static_cast<T *>(other.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
AuSPtr<T> AuStaticCast(AuSPtr<Z> &&other)
|
static AuSPtr<T> AuStaticCast(AuSPtr<Z> &&other)
|
||||||
{
|
{
|
||||||
return AuSPtr<T>(AuMove(other), static_cast<T *>(other.get()));
|
return AuSPtr<T>(AuMove(other), static_cast<T *>(other.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T, class Z>
|
||||||
|
static AuConditional_t<AuIsPointer_v<T>, T, T *> AuStaticCast(Z *other)
|
||||||
|
{
|
||||||
|
return static_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Z>::type)>
|
||||||
|
AuConditional_t<AuIsReference_v<T>, T, T &> AuStaticCast(Z &other)
|
||||||
|
{
|
||||||
|
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &>>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Z>::type)>
|
||||||
|
static AuConditional_t<AuIsReference_v<T>, T, T &&> AuStaticCast(Z &&other)
|
||||||
|
{
|
||||||
|
return static_cast<AuConditional_t<AuIsReference_v<T>, T, T &&>>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsPointer_v<T> && !AuIsPointer_v<Z>)>
|
||||||
|
static T AuStaticCast(Z other)
|
||||||
|
{
|
||||||
|
return static_cast<T>(other);
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *other)
|
AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *other)
|
||||||
{
|
{
|
||||||
return const_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
|
return const_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Z>::type)>
|
||||||
AuConditional_t<AuIsReference_v<T>, T, T &> AuConstCast(Z &other)
|
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 &>>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z, AU_TEMPLATE_ENABLE_WHEN(!AuIsBaseOfTemplate<AURORA_RUNTIME_AU_SHARED_PTR, Z>::type)>
|
||||||
AuConditional_t<AuIsReference_v<T>, T, T &&> AuConstCast(Z &&other)
|
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 &&>>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, class Z>
|
|
||||||
T AuConstCast(Z other)
|
|
||||||
{
|
|
||||||
return const_cast<T>(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
AuSPtr<T> AuConstCast(const AuSPtr<Z> &other)
|
AuSPtr<T> AuConstCast(const AuSPtr<Z> &other)
|
||||||
{
|
{
|
||||||
|
@ -217,7 +217,7 @@ struct is_base_of_template_impl_au
|
|||||||
template<typename... Ts>
|
template<typename... Ts>
|
||||||
static constexpr AuTrueType test(const base<Ts...> *);
|
static constexpr AuTrueType test(const base<Ts...> *);
|
||||||
static constexpr AuFalseType test(...);
|
static constexpr AuFalseType test(...);
|
||||||
using type = decltype(test(std::declval<derived *>()));
|
using type = decltype(test(std::declval<AuRemoveReference_t<derived> *>()));
|
||||||
};
|
};
|
||||||
|
|
||||||
template<template <typename...> class base, typename derived>
|
template<template <typename...> class base, typename derived>
|
||||||
|
Loading…
Reference in New Issue
Block a user