26 template<
class to_t,
class from_t>
27 requires std::derived_from<from_t, rtti_pure_base> && std::derived_from<to_t, rtti_pure_base>
30 if (pointer && pointer->template is_derived_from<to_t>())
31 return static_cast<to_t*
>(pointer);
43 template<
class to_t,
class from_t>
44 requires std::derived_from<from_t, rtti_pure_base> && std::derived_from<to_t, rtti_pure_base>
45 to_t*
rtti_cast(
const std::shared_ptr<from_t>& pValue)
47 if (pValue && pValue->template is_derived_from<to_t>())
48 return static_cast<to_t*
>(pValue.get());
60 template<
class to_t,
class from_t>
61 requires std::derived_from<from_t, rtti_pure_base> && std::derived_from<to_t, rtti_pure_base>
62 to_t*
rtti_cast(
const std::unique_ptr<from_t>& pValue)
64 if (pValue && pValue->template is_derived_from<to_t>())
65 return static_cast<to_t*
>(pValue.get());
77 template<
class to_t,
class from_t>
78 requires std::derived_from<from_t, rtti_pure_base> && std::derived_from<to_t, rtti_pure_base>
81 if (
auto pValue = pValueLink.
lock())
82 if (pValue->template is_derived_from<to_t>())
83 return static_cast<to_t*
>(pValue.get());
96 template<
class to_t,
class from_t>
97 requires std::derived_from<from_t, rtti_pure_base> && std::derived_from<to_t, rtti_pure_base>
100 if (value.template is_derived_from<to_t>())
101 return static_cast<to_t*
>(&value);
std::weak_ptr wrapper that do not allow you to create strong pointer (std::shared_ptr)
lock_ptr lock() const noexcept
Lock and return strong pointer.
RTTI system based on polymorphism.
requires std::derived_from< from_t, rtti_pure_base > &&std::derived_from< to_t, rtti_pure_base > to_t * rtti_cast(from_t *pointer)
Returns to_t* if from_t is inherited from Y, otherwise nullptr.