mrdocs::dyn_cast_or_null

dyn_cast_or_null overloads

Synopses

Dynamic cast if pointer is non‐null and engaged, else nullptr.

template<
    class To,
    class From>
requires ( std::derived_from<std::remove_cvref_t<To>, std::remove_cvref_t<From>> )
[[nodiscard]]
std::add_pointer_t<std::remove_reference_t<To>>
dyn_cast_or_null(Polymorphic<From>* pp) noexcept;

Dynamic cast if pointer is non‐null and engaged, else nullptr (const).

template<
    class To,
    class From>
requires ( std::derived_from<std::remove_cvref_t<To>, std::remove_cvref_t<From>> )
[[nodiscard]]
std::add_pointer_t<std::remove_reference_t<To> const>
dyn_cast_or_null(Polymorphic<From> const* pp) noexcept;

Return Value

Pointer to To when the cast succeeds, otherwise nullptr.

Created with MrDocs