[*] Terachad casts
This commit is contained in:
parent
a7d0e0a261
commit
e4ed0856de
@ -8,9 +8,27 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
T *AuStaticCast(Z *other)
|
AuConditional_t<AuIsPointer_v<T>, T, T *> AuStaticCast(Z *other)
|
||||||
{
|
{
|
||||||
return static_cast<T *>(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>
|
template<class T, class Z>
|
||||||
@ -26,9 +44,27 @@ AuSPtr<T> AuStaticCast(AuSPtr<Z> &&other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
T *AuConstCast(Z *other)
|
AuConditional_t<AuIsPointer_v<T>, T, T *> AuConstCast(Z *other)
|
||||||
{
|
{
|
||||||
return const_cast<T *>(other);
|
return const_cast<AuConditional_t<AuIsPointer_v<T>, T, T *>>(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Z>
|
||||||
|
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>
|
||||||
|
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>
|
template<class T, class Z>
|
||||||
@ -44,9 +80,9 @@ AuSPtr<T> AuConstCast(AuSPtr<Z> &&other)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
T *AuReinterpretCast(Z *other)
|
AuConditional_t<AuIsClass_v<T> && !AuIsPointer_v<T> && AuIsPointer_v<Z>, T *, T> AuReinterpretCast(Z other)
|
||||||
{
|
{
|
||||||
return reinterpret_cast<T *>(other);
|
return reinterpret_cast<AuConditional_t<AuIsClass_v<T> && !AuIsPointer_v<T> &&AuIsPointer_v<Z>, T *, T>>(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, class Z>
|
template<class T, class Z>
|
||||||
|
@ -99,6 +99,15 @@ inline constexpr bool AuIsPointer_v<T *volatile> = true;
|
|||||||
template<class T>
|
template<class T>
|
||||||
inline constexpr bool AuIsPointer_v<T *const volatile> = true;
|
inline constexpr bool AuIsPointer_v<T *const volatile> = true;
|
||||||
|
|
||||||
|
template<class>
|
||||||
|
inline constexpr bool AuIsReference_v = false;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline constexpr bool AuIsReference_v<T &> = true;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline constexpr bool AuIsReference_v<T &&> = true;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct AuRemovePointer
|
struct AuRemovePointer
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user