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,
/* implementation-defined */ Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires(ToQ::quantity_spec == Q::quantity_spec ||
detail::unsatisfied<
"'value_cast' changes only the unit and the representation type, not the quantity type ('{}' to '{}')">(
detail::type_name(Q::quantity_spec),
detail::type_name(ToQ::quantity_spec))) &&
UnitOf<decltype(ToQ::unit), Q::quantity_spec> &&
std::constructible_from<typename ToQ::rep, typename Q::rep> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ 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,
/* implementation-defined */ Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<decltype(ToU), Q::quantity_spec> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires(ToQP::quantity_spec == QP::quantity_spec) &&
UnitOf<decltype(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::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires(ToQ::quantity_spec == QP::quantity_spec ||
detail::unsatisfied<
"'value_cast' changes only the unit and the representation type, not the quantity type ('{}' to '{}')">(
detail::type_name(QP::quantity_spec),
detail::type_name(ToQ::quantity_spec))) &&
UnitOf<decltype(ToQ::unit), QP::quantity_spec> &&
std::constructible_from<typename ToQ::rep, typename QP::rep> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ 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,
/* implementation-defined */ Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<decltype(ToU), QP::quantity_spec> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<decltype(ToU), Q::quantity_spec> &&
RepresentationOf<ToRep, Q::quantity_spec> &&
std::constructible_from<ToRep, typename Q::rep> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires UnitOf<decltype(ToU), Q::quantity_spec> &&
RepresentationOf<ToRep, Q::quantity_spec> &&
std::constructible_from<ToRep, typename Q::rep> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<decltype(ToU), QP::quantity_spec> &&
RepresentationOf<ToRep, QP::quantity_spec> &&
std::constructible_from<ToRep, typename QP::rep> &&
detail::UnitChangeCastable<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,
/* implementation-defined */ Policy = truncated_t,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires UnitOf<decltype(ToU), QP::quantity_spec> &&
RepresentationOf<ToRep, QP::quantity_spec> &&
std::constructible_from<ToRep, typename QP::rep> &&
detail::UnitChangeCastable<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 |
| Policy | the rounding policy, truncated unless a policy is passed |
| 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 |