[#mp_units-quantity_cast-0b] = xref:mp_units.adoc[mp_units]::quantity_cast :relfileprefix: ../ :mrdocs: Explicit cast of a quantity type == Synopsis Declared in `<mp‐units/framework/quantity_cast.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/QuantitySpec.adoc[QuantitySpec] auto ToQS, typename FwdQ, xref:mp_units/Quantity.adoc[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 xref:mp_units/Quantity.adoc[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] ---- {.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 [cols=2] |=== | Name | Description | *ToQS* | a quantity specification to use for a target quantity |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#