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/customization_points.h>
template<
    auto FromUnit,
    typename FromRep,
    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 FromRep is convertible to ToRep and 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.

NOTE

The default initializer references is_integral_scaling, which is defined in <mp-units/framework/value_cast.h>. The unqualified call is found via ADL at instantiation time, so any translation unit that instantiates this template must have value_cast.h (or a header transitively including it) included.

Template Parameters

Name Description
FromUnit the source unit value (NTTP)
FromRep the source representation type
ToUnit the target unit value (NTTP)
ToRep the target representation type