mp_units::quantity_cast

quantity_cast overloads

Synopses

Declared in <mp-units/framework/quantity_cast.h>

Explicit cast of a quantity type

template<
    QuantitySpec auto ToQS,
    typename FwdQ,
    Quantity Q = std::remove_cvref_t<FwdQ>>
requires (mp_units::castable(Q::quantity_spec, ToQS)) &&
          requires { typename quantity<make_reference(ToQS, Q::unit), typename Q::rep>; }
[[nodiscard]]
constexpr
Quantity auto
quantity_cast(FwdQ&& q);
» more...

Explicit cast of a quantity point type

template<
    QuantitySpec auto ToQS,
    typename FwdQP,
    QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (mp_units::castable(QP::quantity_spec, ToQS)) &&
          requires { typename quantity_point<make_reference(ToQS, QP::unit), QP::point_origin, typename QP::rep>; }
[[nodiscard]]
constexpr
QuantityPoint auto
quantity_cast(FwdQP&& qp);
» more...

Return Value

  • the quantity with its quantity type recast to ToQS
  • the quantity point with its quantity type recast to ToQS

NOTE

The return value should not be discarded.

Template Parameters

NameDescription
ToQSa quantity specification to use for a target quantity

Parameters

NameDescription
qthe quantity to cast
qpthe quantity point to cast