|
quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
|
Trait giving the display suffix for a (unit, precision) pair. More...
#include <quanta/spatial.hpp>
Static Public Member Functions | |
| static std::string | value () |
| Returns the display suffix. | |
Trait giving the display suffix for a (unit, precision) pair.
A specialization provides static std::string value(), the default suffix, and may also provide static std::string power_value(), the power-form suffix (the precision written as a power of a length unit, as selected by to_string(q, power_form) or the p format marker). When power_value() is absent the power form is the same as value(). A (unit, precision) pair without value() has no suffix, and quantities of it cannot be converted to strings or formatted.
For lengths, the primary template combines an SI prefix with the unit symbol (e.g. "mm", "km") and is only usable when the precision is a standard SI prefix. Full specializations provide the conventional suffixes for the imperial and nautical precisions: "mil", "in", "ft", "yd", "mi" and "nmi". A length's power form is its default suffix.
For areas and volumes the SI prefix rule does not apply, since a prefix scales the length before it is squared or cubed (a millimeter squared is 10⁻⁶ m², not 10⁻³ m²). Only these precisions have suffixes, shown as default / power form where they differ:
The base-unit and scaled forms (see base_unit and scaled) do not use these suffixes for metric precisions, i.e. those that are powers of ten of the base unit: they compute the value in the base unit or in a unit chosen by magnitude. The scaled form shows other precisions with value().
| Unit | The unit tag type. |
| Precision | The (reduced) precision ratio. |
Definition at line 909 of file spatial.hpp.
|
inlinestatic |
Returns the display suffix.
Definition at line 911 of file spatial.hpp.
Referenced by quanta::spatial::to_string().