mrdocs::dyn_cast_or_null

dyn_cast_or_null overloads

Synopses

Declared in <mrdocs/ADT/Polymorphic.hpp>

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;
» more...

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;
» more...

Return Value

Pointer to To when the cast succeeds, otherwise nullptr.

NOTE

The return value should not be discarded.