mrdocs::cast

Dynamic cast returning const reference; asserts on failure.

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::remove_reference_t<To> const&
cast(Polymorphic<From> const& p);

Return Value

Const reference to the contained object cast to To.

Parameters

Name Description

p

A polymorphic value‐type.

Created with MrDocs