mrdocs::cast

Dynamic cast returning reference; asserts on failure.

Synopsis

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

Return Value

Reference to the contained object cast to To.

The return value should not be discarded.

Parameters

Name

Description

p

A polymorphic value‐type.

Created with MrDocs