<mp-units/framework/value_cast.h>
template<
typename ToRep,
typename FwdQ,
Quantity Q = std::remove_cvref_t<FwdQ>>
requires RepresentationOf<ToRep, Q::quantity_spec> && std::constructible_from<ToRep, typename Q::rep>
[[nodiscard]]
constexpr
quantity<Q::reference, ToRep>
value_cast(FwdQ&& q);
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 q = value_cast<int>(1.23 ms);
Name | Description |
---|---|
ToRep | a representation type to use for a target quantity |