/*** Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: auCastUtils.hpp Date: 2022-2-10 Author: Reece ***/ #pragma once template static constexpr AuSPtr AuStaticCast(const AuSPtr &other) { return AuSPtr(other, static_cast(other.get())); } template static constexpr AuSPtr AuStaticCast(AuSPtr &&other) { return AuSPtr(AuMove(other), static_cast(other.get())); } template static constexpr AuConditional_t, T, T *> AuStaticCast(Z *other) { return static_cast, T, T *>>(other); } template static constexpr AuConditional_t, const AuRemoveConst_t, const AuRemoveConst_t *> AuStaticCast(const Z *other) { return static_cast, const AuRemoveConst_t, const AuRemoveConst_t *>>(other); } template && AuIsLValueReference_v)> static constexpr AuConditional_t, T, T &> AuStaticCast(Z other) { return static_cast, T, T &>>(AuForward(other)); } template && AuIsRValueReference_v)> static constexpr AuConditional_t, T, T &&> AuStaticCast(Z other) { return static_cast, T, T &&>>(AuMove(other)); } template && !AuIsReference_v)> static constexpr T AuStaticCast(Z other) { return static_cast(other); } template &&AuIsRValueReference_v)> static constexpr AuConditional_t, T, T *> AuConstCast(Z *other) { return const_cast, T, T *>>(other); } template )> static constexpr AuConditional_t, T, T &> AuConstCast(Z &other) { return const_cast, T, T &>>(AuForward(other)); } template )> static constexpr AuConditional_t, T, T &&> AuConstCast(Z &&other) { return const_cast, T, T &&>>(AuMove(other)); } template static constexpr AuSPtr AuConstCast(const AuSPtr &other) { return AuSPtr(other, const_cast(other.get())); } template static constexpr AuSPtr AuConstCast(AuSPtr &&other) { return AuSPtr(AuMove(other), const_cast(other.get())); } template static constexpr AuConditional_t && !AuIsPointer_v && !AuIsReference_v, T *, T> AuReinterpretCast(Z other) { return reinterpret_cast && !AuIsPointer_v && !AuIsReference_v, T *, T>>(other); } template static constexpr AuConditional_t && !AuIsPointer_v && !AuIsReference_v, const T *, const T> AuReinterpretCast(const Z *other) { return reinterpret_cast && !AuIsPointer_v && !AuIsReference_v, const AuRemoveConst_t *, const AuRemoveConst_t>>(other); } template static constexpr AuSPtr AuReinterpretCast(const AuSPtr &other) { return AuSPtr(other, reinterpret_cast(other.get())); } template static constexpr AuSPtr AuReinterpretCast(AuSPtr &&other) { return AuSPtr(AuMove(other), reinterpret_cast(other.get())); } template static T *AuDynamicCast(Z *other) { return dynamic_cast(other); } template static AuSPtr AuDynamicCast(const AuSPtr &other) { return AuSPtr(other, dynamic_cast(other.get())); } template static AuSPtr AuDynamicCast(AuSPtr &&other) { return AuSPtr(AuMove(other), dynamic_cast(other.get())); } template static AuOptional> AuOptionalSharedDynamicCast(AuOptional> &in) { if (!in.has_value()) return {}; return AuDynamicCast(in.value()); } template static AuOptional> AuOptionalSharedStaticCast(AuOptional> &in) { if (!in.has_value()) return {}; return AuStaticPointerCast(in.value()); } template static AuSPtr AuStaticPointerCast(const AuSPtr &other) noexcept { return AuSPtr(other, static_cast::element_type *>(other.get())); } template static AuSPtr AuStaticPointerCast(AuSPtr &&other) noexcept { return AuSPtr(AuMove(other), static_cast::element_type *>(other.get())); }