mrdocs::cast_or_null

Dynamic cast pointer; returns nullptr when pp is null.

Synopsis

Declared in <mrdocs/ADT/Polymorphic.hpp>

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>>
cast_or_null(Polymorphic<From>* pp);

Return Value

Pointer to To when the cast succeeds, otherwise nullptr.

NOTE

The return value should not be discarded.

Parameters

NameDescription
ppA polymorphic value-type.