[*] Work out additional kinks in casts

This commit is contained in:
Reece Wilson 2022-03-10 00:57:48 +00:00
parent e4ed0856de
commit 216587195e
2 changed files with 29 additions and 35 deletions

View File

@ -8,65 +8,59 @@
#pragma once
template<class T, class Z>
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>
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)
static AuSPtr<T> AuStaticCast(const AuSPtr<Z> &other)
{
return AuSPtr<T>(other, static_cast<T *>(other.get()));
}
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()));
}
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>
AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *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)
{
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)
{
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>
AuSPtr<T> AuConstCast(const AuSPtr<Z> &other)
{

View File

@ -217,7 +217,7 @@ struct is_base_of_template_impl_au
template<typename... Ts>
static constexpr AuTrueType test(const base<Ts...> *);
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>