[#mp_units-value_cast-021] = xref:mp_units.adoc[mp_units]::value_cast :relfileprefix: ../ :mrdocs: Explicit cast of a quantity point's representation type == Synopsis Declared in `<mp‐units/framework/value_cast.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename ToRep, typename FwdQP, xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> [[nodiscard]] constexpr xref:mp_units/quantity_point-08.adoc[quantity_point<QP::reference, QP::point_origin, ToRep>] value_cast(FwdQP&& qp); ---- == Description Implicit conversions between quantity points of different types are allowed only for "safe" (e.g. non‐truncating) conversion. In truncating cases an explicit cast have to be used. auto qp = value_cast<int>(quantity_point{1.23 * ms}); == Return Value A quantity point == Template Parameters [cols=2] |=== | Name | Description | *ToRep* | a representation type to use for a target quantity point |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#