mp_units::value_cast¶
value_cast overloads
Synopses¶
Declared in <mp-units/framework/value_cast.h>
Explicit cast of a quantity's representation
template<Quantity ToQ, typename FwdQ, RoundingPolicy Policy = truncated_t, 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 Quantity auto value_cast(FwdQ&& q, Policy = Policy{});
Explicit cast of a quantity's representation type
template<typename ToRep, typename FwdQ, RoundingPolicy Policy = truncated_t, 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 quantity<Q::reference, ToRep> value_cast(FwdQ&& q, Policy = Policy{});
Explicit cast of a quantity's unit
template<auto ToU, typename FwdQ, RoundingPolicy Policy = truncated_t, Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<MP_UNITS_NTTP_TYPE(ToU), Q::quantity_spec> &&
detail::ExplicitlyCastable<Q::unit, ToU, typename Q::rep> &&
detail::ValidRoundingPolicyFor<Policy, typename Q::rep, typename Q::rep>
[[nodiscard]] constexpr Quantity auto value_cast(FwdQ&& q, Policy = Policy{});
Explicit cast of a quantity point's representation, including potentially the point origin
template<QuantityPoint ToQP, typename FwdQP, RoundingPolicy Policy = truncated_t,
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 QuantityPoint auto value_cast(FwdQP&& qp, Policy = Policy{});
Explicit cast of a quantity point's representation
template<Quantity ToQ, typename FwdQP, RoundingPolicy Policy = truncated_t,
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 QuantityPoint auto value_cast(FwdQP&& qp, Policy policy = Policy{});
Explicit cast of a quantity point's representation type
template<typename ToRep, typename FwdQP, RoundingPolicy Policy = truncated_t,
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 quantity_point<QP::reference, QP::point_origin, ToRep> value_cast(FwdQP&& qp,
Policy policy = Policy{});
Explicit cast of a quantity point's unit
template<Unit auto ToU, typename FwdQP, RoundingPolicy Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<MP_UNITS_NTTP_TYPE(ToU), QP::quantity_spec> &&
detail::ExplicitlyCastable<QP::unit, ToU, typename QP::rep> &&
detail::ValidRoundingPolicyFor<Policy, typename QP::rep, typename QP::rep>
[[nodiscard]] constexpr QuantityPoint auto value_cast(FwdQP&& qp, Policy policy = Policy{});
Explicit cast of a quantity's unit and representation type
template<Unit auto ToU, typename ToRep, typename FwdQ, RoundingPolicy Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<MP_UNITS_NTTP_TYPE(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 Quantity auto value_cast(FwdQ&& q, Policy = Policy{});
template<typename ToRep, Unit auto ToU, typename FwdQ, RoundingPolicy Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<MP_UNITS_NTTP_TYPE(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 Quantity auto value_cast(FwdQ&& q, Policy policy = Policy{});
template<typename ToRep, Unit auto ToU, typename FwdQP, RoundingPolicy Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<MP_UNITS_NTTP_TYPE(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 QuantityPoint auto value_cast(FwdQP&& qp, Policy policy = Policy{});
Explicit cast of a quantity point's unit and representation type
template<Unit auto ToU, typename ToRep, typename FwdQP, RoundingPolicy Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<MP_UNITS_NTTP_TYPE(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 QuantityPoint auto value_cast(FwdQP&& qp, Policy policy = Policy{});
Return Value¶
Note
The return value should not be discarded.
Template Parameters¶
| 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¶
| Name | Description |
|---|---|
| policy | an optional rounding policy (truncated when not provided) |