quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
Loading...
Searching...
No Matches
quanta::spatial::quantity_suffix< Unit, Precision > Struct Template Reference

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.
 

Detailed Description

template<typename Unit, typename Precision>
struct quanta::spatial::quantity_suffix< Unit, Precision >

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:

  • Area: nm², µm², mm², cm², m², ha / hm², km², mil², in², ft², yd², ac, mi² and nmi².
  • Volume: µm³, µL / mm³, mL / cm³, L / dm³, m³, km³, in³, ft³, yd³, mi³, nmi³ and gal (US gallon).

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().

Template Parameters
UnitThe unit tag type.
PrecisionThe (reduced) precision ratio.

Definition at line 909 of file spatial.hpp.

Member Function Documentation

◆ value()

template<typename Unit , typename Precision >
static std::string quanta::spatial::quantity_suffix< Unit, Precision >::value ( )
inlinestatic

Returns the display suffix.

Definition at line 911 of file spatial.hpp.

Referenced by quanta::spatial::to_string().


The documentation for this struct was generated from the following file: