mrdocs::dyn_cast

Dynamic cast returning pointer or nullptr.

Synopsis

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(Polymorphic<From>& p) noexcept;

Return Value

Pointer to To if the dynamic cast succeeds, otherwise nullptr.

The return value should not be discarded.

Parameters

Name

Description

p

A polymorphic value‐type.

Created with MrDocs