cast overloads

Synopses

Declared in <mrdocs/ADT/Polymorphic.hpp>

Dynamic cast returning reference; asserts on failure.

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);

Dynamic cast returning const reference; asserts on failure.

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

  • Reference to the contained object cast to To.

  • Const reference to the contained object cast to To.

Created with MrDocs