/*** 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 AuConditional_t, T, T *> AuStaticCast(Z *other) { return static_cast, T, T *>>(other); } template AuConditional_t, T, T &> AuStaticCast(Z &other) { return static_cast, T, T &>>(other); } template AuConditional_t, T, T &&> AuStaticCast(Z &&other) { return static_cast, T, T &&>>(other); } template T AuStaticCast(Z other) { return static_cast(other); } template AuSPtr AuStaticCast(const AuSPtr &other) { return AuSPtr(other, static_cast(other.get())); } template AuSPtr AuStaticCast(AuSPtr &&other) { return AuSPtr(AuMove(other), static_cast(other.get())); } template AuConditional_t, T, T *> AuConstCast(Z *other) { return const_cast, T, T *>>(other); } template AuConditional_t, T, T &> AuConstCast(Z &other) { return const_cast, T, T &>>(other); } template AuConditional_t, T, T &&> AuConstCast(Z &&other) { return const_cast, T, T &&>>(other); } template T AuConstCast(Z other) { return const_cast(other); } template AuSPtr AuConstCast(const AuSPtr &other) { return AuSPtr(other, const_cast(other.get())); } template AuSPtr AuConstCast(AuSPtr &&other) { return AuSPtr(AuMove(other), const_cast(other.get())); } template AuConditional_t && !AuIsPointer_v && AuIsPointer_v, T *, T> AuReinterpretCast(Z other) { return reinterpret_cast && !AuIsPointer_v &&AuIsPointer_v, T *, T>>(other); } template AuSPtr AuReinterpretCast(const AuSPtr &other) { return AuSPtr(other, reinterpret_cast(other.get())); } template AuSPtr AuReinterpretCast(AuSPtr &&other) { return AuSPtr(AuMove(other), reinterpret_cast(other.get())); } template T *AuDynamicCast(Z *other) { return dynamic_cast(other); } template AuSPtr AuDynamicCast(const AuSPtr &other) { return AuSPtr(other, dynamic_cast(other.get())); } template AuSPtr AuDynamicCast(AuSPtr &&other) { return AuSPtr(AuMove(other), dynamic_cast(other.get())); } template AuOptional> AuOptionalSharedDynamicCast(AuOptional> &in) { if (!in.has_value()) return {}; return AuDynamicCast(in.value()); } template AuOptional> AuOptionalSharedStaticCast(AuOptional> &in) { if (!in.has_value()) return {}; return AuStaticPointerCast(in.value()); } template AuSPtr AuStaticPointerCast(const AuSPtr &other) noexcept { return AuSPtr(other, static_cast::element_type *>(other.get())); } template AuSPtr AuStaticPointerCast(AuSPtr &&other) noexcept { return AuSPtr(AuMove(other), static_cast::element_type *>(other.get())); }