![]() |
Home | Libraries | People | FAQ | More |
If a unit has a special name and/or symbol, the free functions name_string
and symbol_string
can be overloaded directly.
std::string name_string(const cgs::force&) { return "dyne"; } std::string symbol_string(const cgs::force&) { return "dyn"; }
In this case, any unit that reduces to the overloaded unit will be output with the replacement symbol.
Special names and symbols for the SI and CGS unit systems are found in boost/units/systems/si/io.hpp
and boost/units/systems/cgs/io.hpp
,
respectively. If these headers are not included, the output will simply follow
default rules using the appropriate fundamental dimensions. Note that neither
of these functions is defined for quantities because doing so would require
making assumptions on how the corresponding value type should be formatted.
Three ostream
formatters,
symbol_format
, name_format
, and typename_format
are provided for convenience. These select the textual representation of
units provided by symbol_string
or name_string
in the first
two cases, while the latter returns a demangled typename for debugging purposes.
Formatting of scaled unit is also done correctly.