4 General utilities library [utilities]

4.2 Utility components [utility]

4.2.3 static_­downcast [static.downcast]

A static_­cast that performs a downcast.
template <class DerivedRef, class Base> constexpr DerivedRef static_downcast(Base&& base) noexcept;
Let derived-ref be static_­cast<DerivedRef>(std​::​forward<Base>(base)).
Constraints:
  • DerivedRef is a reference type,
  • std​::​remove_­cvref_­t<DerivedRef> is derived from std​::​remove_­cvref_­t<Base>, and
  • derived-ref is well-formed.
Preconditions: derived-ref has well-defined behavior.
Returns: derived-ref.