[#mp_units-value_cast-03d] = xref:mp_units.adoc[mp_units]::value_cast :relfileprefix: ../ :mrdocs: `value_cast` overloads == Synopses Declared in `<mp‐units/framework/value_cast.h>` Explicit cast of a quantity's representation [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/Quantity-0c.adoc[Quantity] ToQ, typename FwdQ, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/Quantity-0c.adoc[Quantity] Q = std::remove_cvref_t<FwdQ>> requires (ToQ::quantity_spec == Q::quantity_spec) && UnitOf<MP_UNITS_NONCONST_TYPE(ToQ::unit), Q::quantity_spec> && std::constructible_from<typename ToQ::rep, typename Q::rep> && detail::ExplicitlyCastable<Q::unit, ToQ::unit, typename ToQ::rep> && detail::ValidRoundingPolicyFor<Policy, typename Q::rep, typename ToQ::rep> [[nodiscard]] constexpr xref:mp_units/Quantity-0c.adoc[Quantity] auto xref:mp_units/value_cast-0ac.adoc[value_cast]( FwdQ&& q, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-0ac.adoc[_» more..._]# Explicit cast of a quantity's representation type [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename ToRep, typename FwdQ, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/Quantity-0c.adoc[Quantity] Q = std::remove_cvref_t<FwdQ>> requires RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep> && detail::ValidRoundingPolicyFor<Policy, typename Q::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/quantity-01.adoc[quantity<Q::reference, ToRep>] xref:mp_units/value_cast-04.adoc[value_cast]( FwdQ&& q, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-04.adoc[_» more..._]# Explicit cast of a quantity's unit [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< auto ToU, typename FwdQ, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/Quantity-0c.adoc[Quantity] Q = std::remove_cvref_t<FwdQ>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec> && detail::ExplicitlyCastable<Q::unit, ToU, typename Q::rep> && detail::ValidRoundingPolicyFor<Policy, typename Q::rep, typename Q::rep> [[nodiscard]] constexpr xref:mp_units/Quantity-0c.adoc[Quantity] auto xref:mp_units/value_cast-06.adoc[value_cast]( FwdQ&& q, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-06.adoc[_» more..._]# Explicit cast of a quantity point's representation [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/Quantity-0c.adoc[Quantity] ToQ, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires (ToQ::quantity_spec == QP::quantity_spec) && UnitOf<MP_UNITS_NONCONST_TYPE(ToQ::unit), QP::quantity_spec> && std::constructible_from<typename ToQ::rep, typename QP::rep> && detail::ExplicitlyCastable<QP::unit, ToQ::unit, typename ToQ::rep> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, typename ToQ::rep> [[nodiscard]] constexpr xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto xref:mp_units/value_cast-02.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-02.adoc[_» more..._]# Explicit cast of a quantity point's representation, including potentially the point origin [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/QuantityPoint.adoc[QuantityPoint] ToQP, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires (ToQP::quantity_spec == QP::quantity_spec) && UnitOf<MP_UNITS_NONCONST_TYPE(ToQP::unit), QP::quantity_spec> && (detail::same_absolute_point_origins(ToQP::point_origin, QP::point_origin)) && std::constructible_from<typename ToQP::rep, typename QP::rep> && detail::ExplicitlyCastable<QP::unit, ToQP::unit, typename ToQP::rep> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, typename ToQP::rep> [[nodiscard]] constexpr xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto xref:mp_units/value_cast-034.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-034.adoc[_» more..._]# Explicit cast of a quantity point's representation type [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename ToRep, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], 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> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/quantity_point-08.adoc[quantity_point<QP::reference, QP::point_origin, ToRep>] xref:mp_units/value_cast-0c.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-0c.adoc[_» more..._]# Explicit cast of a quantity point's unit [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/Unit.adoc[Unit] auto ToU, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec> && detail::ExplicitlyCastable<QP::unit, ToU, typename QP::rep> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, typename QP::rep> [[nodiscard]] constexpr xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto xref:mp_units/value_cast-0ad.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-0ad.adoc[_» more..._]# Explicit cast of a quantity's representation type and unit [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename ToRep, xref:mp_units/Unit.adoc[Unit] auto ToU, typename FwdQ, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/Quantity-0c.adoc[Quantity] Q = std::remove_cvref_t<FwdQ>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec> && RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep> && detail::ExplicitlyCastable<Q::unit, ToU, ToRep> && detail::ValidRoundingPolicyFor<Policy, typename Q::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/Quantity-0c.adoc[Quantity] auto xref:mp_units/value_cast-09.adoc[value_cast]( FwdQ&& q, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-09.adoc[_» more..._]# Explicit cast of a quantity's unit and representation type [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/Unit.adoc[Unit] auto ToU, typename ToRep, typename FwdQ, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/Quantity-0c.adoc[Quantity] Q = std::remove_cvref_t<FwdQ>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), Q::quantity_spec> && RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep> && detail::ExplicitlyCastable<Q::unit, ToU, ToRep> && detail::ValidRoundingPolicyFor<Policy, typename Q::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/Quantity-0c.adoc[Quantity] auto xref:mp_units/value_cast-00.adoc[value_cast]( FwdQ&& q, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-00.adoc[_» more..._]# Explicit cast of a quantity point's representation type and unit [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< typename ToRep, xref:mp_units/Unit.adoc[Unit] auto ToU, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec> && RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> && detail::ExplicitlyCastable<QP::unit, ToU, ToRep> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto xref:mp_units/value_cast-0f.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-0f.adoc[_» more..._]# Explicit cast of a quantity point's unit and representation type [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< xref:mp_units/Unit.adoc[Unit] auto ToU, typename ToRep, typename FwdQP, xref:mp_units/RoundingPolicy.adoc[RoundingPolicy] Policy = xref:mp_units/truncated_t.adoc[truncated_t], xref:mp_units/QuantityPoint.adoc[QuantityPoint] QP = std::remove_cvref_t<FwdQP>> requires UnitOf<MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec> && RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> && detail::ExplicitlyCastable<QP::unit, ToU, ToRep> && detail::ValidRoundingPolicyFor<Policy, typename QP::rep, ToRep> [[nodiscard]] constexpr xref:mp_units/QuantityPoint.adoc[QuantityPoint] auto xref:mp_units/value_cast-0d.adoc[value_cast]( FwdQP&& qp, Policy policy = Policy{}); ---- [.small]#xref:mp_units/value_cast-0d.adoc[_» more..._]# == Return Value * the quantity converted to quantity type `ToQ` * the quantity converted to representation type `ToRep` * the quantity converted to unit `ToU` * the quantity point with its quantity‐from‐origin cast to `ToQ` * the quantity point cast to `ToQP` * the quantity point converted to representation type `ToRep` * the quantity point converted to unit `ToU` * the quantity converted to unit `ToU` and representation type `ToRep` * the quantity point converted to unit `ToU` and representation type `ToRep` [NOTE] ==== The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^]. ==== == Template Parameters [cols="1,4"] |=== | Name| Description | *ToQ* | a target quantity type to which to cast the representation | *ToRep* | a representation type to use for a target quantity | *ToU* | a unit to use for a target quantity | *ToQP* | a target quantity point type to which to cast the representation of the point |=== == Parameters [cols="1,4"] |=== | Name| Description | *q* | the quantity to cast | *policy* | an optional rounding policy (`truncated` when not provided) | *qp* | the quantity point to cast |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#