mp_units::scale

Scale value by the unit magnitude passed as m, converting to type To.

Synopsis

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

template<
    typename To,
    UnitMagnitude M,
    typename From>
requires detail::UnitMagnitudeScalable<From>
[[nodiscard]]
constexpr
auto
scale(
    M m,
    From const& value);

Description

When From provides a magnitude-aware operator*(From,M) customization point, it is used first. The return type may differ from To (e.g. a representation with scaled bounds). Otherwise, the built-in floating-point or integer path is used and the result type is To.

Use this in custom operator*(T, UnitMagnitude) implementations to reuse the library's built-in scaling logic instead of duplicating it.

Return Value

value scaled by m, truncated to type To

NOTE

The return value should not be discarded.

Parameters

NameDescription
munit magnitude to scale value by
valuevalue being scaled