21 template<
class T,
class from_t>
22 concept has_is_derived_from = requires(T* t) { t->template is_derived_from<from_t>(); };
34 template<
class Y,
class X>
37 using T = std::decay_t<X>;
40 using smart_pointer_t =
typename std::remove_reference_t<decltype(value)>::element_type;
41 if constexpr (details::has_is_derived_from<smart_pointer_t, Y>)
42 if (value && value->template is_derived_from<Y>())
43 return static_cast<Y*
>(value.get());
47 if constexpr (details::has_is_derived_from<T, Y>)
48 if (value.template is_derived_from<Y>())
49 return static_cast<Y*
>(&value);
63 template<
class Y,
class X>
66 if constexpr (details::has_is_derived_from<X, Y>)
67 if (pointer && pointer->template is_derived_from<Y>())
68 return static_cast<Y*
>(pointer);
Y * rtti_cast(X &value)
Returns Y* if X or element_type of X is inherited from Y, otherwise nullptr.