mp_units::si::invoke_with_prefixed¶
Calls an invocable with a quantity scaled to an automatically selected SI prefix
Synopsis¶
Declared in <mp-units/systems/si/prefix_utils.h>
template<Quantity Q, std::invocable<Q> Func, PrefixableUnit U, auto Character = quantity_character{}>
requires RepresentationOf<typename Q::rep, Character> && treat_as_floating_point<typename Q::rep> &&
requires(Q::rep v) {
requires requires { abs(v); } || requires { std::abs(v); };
requires requires { log10(v); } || requires { std::log10(v); };
requires requires { floor(v); } || requires { std::floor(v); };
}
constexpr decltype(auto) invoke_with_prefixed(Func func, Q q, U u, prefix_range range = prefix_range::engineering,
int min_integral_digits = 1);
Description¶
Selects an SI prefix such that the integral part of the quantity's numerical value has at least min_integral_digits digits.
NOTE
For
min_integral_digits=1
- engineering mode: values displayed in range [1.0, 999.999...]
- full mode: values displayed in range [1.0, 9.999...]
Return Value¶
The result of calling func with the scaled quantity
Template Parameters¶
| Name | Description |
|---|---|
| Q | Quantity type |
| Func | Invocable type that accepts a quantity |
| U | PrefixableUnit type |
Parameters¶
| Name | Description |
|---|---|
| func | Invocable to call with the scaled quantity |
| q | Quantity to scale |
| u | Unit to use as the base for prefix selection |
| range | Prefix selection mode: - prefix_range::engineering selects only powers of 1000 (kilo, mega, milli, etc.), resulting in values in range [1.0, 1000)] - prefix_range::full selects all SI prefixes including deca, hecto, deci, centi, resulting in values values in [1.0, 10) within the milli–kilo range, [1.0, 1000) elsewhere]] |
| min_integral_digits | Minimum number of digits in the integral part (default: 1) |