mp_units::quantity_cast

Explicit cast of a quantity type

Synopsis

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


Description

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

For example:

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

NOTE

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

Template Parameters

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

Created with MrDocs