mp_units::quantity_cast

Explicit cast of a quantity point type

Synopsis

Declared in <mp-units/framework/quantity_cast.h>
template<
    QuantitySpec auto ToQS,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (castable(QP::quantity_spec, ToQS)) && (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_NONCONST_TYPE(QP::unit), ToQS))
[[nodiscard]]
constexpr
QuantityPoint auto
quantity_cast(FwdQP&& qp);


Description

This cast converts only a quantity point type. It might be used to force some quantity point type conversions that are not implicitly allowed but are allowed explicitly.

For example:

{.cpp} auto length = isq::length(quantity_point{42 * m}); auto altitude = quantity_cast(length);

NOTE

This cast does not affect the underlying value of a number stored in a quantity point.

Template Parameters

Name Description
ToQS a quantity specification to use for a target quantity point

Created with MrDocs