mp_units::implicitly_scalable

Controls whether conversion from quantity<FromUnit, FromRep> to quantity<ToUnit, ToRep> is implicit or explicit.

Synopsis

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

template<
    Unit auto FromUnit,
    typename FromRep,
    Unit auto ToUnit,
    typename ToRep>
constexpr bool implicitly_scalable = treat_as_floating_point<ToRep> || (!treat_as_floating_point<FromRep> && is_integral_scaling(FromUnit, ToUnit));

Description

The default is true iff the scaling is non-truncating: either ToRep is floating-point, or both reps are non-floating-point and the unit magnitude ratio is an integral factor.

Specialize this variable template to customize the implicit/explicit decision for your own representation types.

Template Parameters

NameDescription
FromUnitthe source unit value (NTTP)
FromRepthe source representation type
ToUnitthe target unit value (NTTP)
ToRepthe target representation type