<mp-units/framework/value_cast.h>
template<
Unit auto ToU,
typename ToRep,
typename FwdQP,
QuantityPoint QP = std::remove_cvref_t<FwdQP>>
requires (MP_UNITS_WEAK_UNIT_OF(MP_UNITS_REMOVE_CONST(decltype(ToU)), QP::quantity_spec)) &&
RepresentationOf<ToRep, QP::quantity_spec> && std::constructible_from<ToRep, typename QP::rep> &&
detail::SaneScaling<QP::unit, ToU, ToRep>
[[nodiscard]]
constexpr
QuantityPoint auto
value_cast(FwdQP&& qp);
Implicit conversions between quantities 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<us, int>(quantity_point{1.23 ms});
Name | Description |
---|---|
ToU | a unit to use for the target quantity |
ToRep | a representation type to use for the target quantity |