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::MagnitudeScalable<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, fixed‐point, or element‐wise 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.

Created with MrDocs