Refureku v2.2.0
C++17 runtime reflection library.
Cast.h
1
8#pragma once
9
10#include <type_traits> //std::is_class_v, is_base_of_v
11#include <cassert>
12
13#include "Refureku/TypeInfo/Archetypes/GetArchetype.h"
14#include "Refureku/Misc/CopyConstness.h"
15#include "Refureku/Misc/TypeTraits.h" //isCallable_static_staticGetArchetype, isCallable_getArchetype
16
17namespace rfk
18{
19 //Forward declaration
20 class Struct;
21
32 template <typename TargetClassType, typename SourceClassType>
33 RFK_NODISCARD TargetClassType* dynamicCast(SourceClassType* instance) noexcept;
34
47 template <typename TargetClassType>
48 RFK_NODISCARD TargetClassType* dynamicCast(typename CopyConstness<TargetClassType, void>::Type* instance,
49 Struct const& instanceStaticArchetype,
50 Struct const& instanceDynamicArchetype,
51 Struct const& targetArchetype) noexcept;
52
67 template <typename TargetClassType>
68 RFK_NODISCARD TargetClassType* dynamicUpCast(typename CopyConstness<TargetClassType, void>::Type* instance,
69 Struct const& targetArchetype) noexcept;
70
85 template <typename TargetClassType>
86 RFK_NODISCARD TargetClassType* dynamicDownCast(typename CopyConstness<TargetClassType, void>::Type* instance,
87 Struct const& instanceStaticArchetype,
88 Struct const& targetArchetype) noexcept;
89
90 namespace internal
91 {
102 RFK_NODISCARD REFUREKU_API void* dynamicCast(void* instance,
103 Struct const& instanceStaticArchetype,
104 Struct const& instanceDynamicArchetype,
105 Struct const& targetArchetype) noexcept;
106
118 RFK_NODISCARD REFUREKU_API void const* dynamicCast(void const* instance,
119 Struct const& instanceStaticArchetype,
120 Struct const& instanceDynamicArchetype,
121 Struct const& targetArchetype) noexcept;
122
134 RFK_NODISCARD REFUREKU_API void* dynamicUpCast(void* instance,
135 Struct const& instanceStaticArchetype,
136 Struct const& targetArchetype) noexcept;
137
150 RFK_NODISCARD REFUREKU_API void const* dynamicUpCast(void const* instance,
151 Struct const& instanceStaticArchetype,
152 Struct const& targetArchetype) noexcept;
153
165 RFK_NODISCARD REFUREKU_API void* dynamicDownCast(void* instance,
166 Struct const& instanceStaticArchetype,
167 Struct const& targetArchetype) noexcept;
168
181 RFK_NODISCARD REFUREKU_API void const* dynamicDownCast(void const* instance,
182 Struct const& instanceStaticArchetype,
183 Struct const& targetArchetype) noexcept;
184 }
185
186 #include "Refureku/TypeInfo/Cast.inl"
187}
Definition: Struct.h:40
Definition: Allocator.h:16
RFK_NODISCARD TargetClassType * dynamicDownCast(typename CopyConstness< TargetClassType, void >::Type *instance, Struct const &instanceStaticArchetype, Struct const &targetArchetype) noexcept
Adjust the pointer of the provided instance of type instanceStaticArchetype to a pointer to a targetA...
RFK_NODISCARD TargetClassType * dynamicUpCast(typename CopyConstness< TargetClassType, void >::Type *instance, Struct const &targetArchetype) noexcept
Adjust the pointer of the provided instance of type instanceStaticArchetype to a pointer to a targetA...
RFK_NODISCARD TargetClassType * dynamicCast(SourceClassType *instance) noexcept
Adjust the provided pointer to another class pointer if possible.