Skip to content

mp_units::no_space_before_unit_symbol

Writes a unit's symbol directly after the number, with no space between them

Synopsis

Declared in <mp-units/framework/unit_concepts.h>

inline constexpr no_space_before_unit_symbol no_space_before_unit_symbol;

Description

The SI separates a number from a unit symbol with a space, and makes an exception only for the degree, minute and second of plane angle: 90°, 30′, 15″. A unit that follows the same convention passes this tag to named_unit, after the other arguments and before or after a point origin:

// right ascension in astronomy is written as 5ʰ 35ᵐ, with no space
inline constexpr struct hour_angle final :
  named_unit<symbol_text{u8"ʰ", "h"}, mag<15> * non_si::degree, no_space_before_unit_symbol> {} hour_angle;

void print_right_ascension() { std::cout << 5 * hour_angle << '\n'; }  // 5ʰ

A prefixed unit, or another named_unit defined in terms of a unit that passes the tag, has a symbol of its own, so it is printed with the space unless it passes the tag too. A format specification without %?, such as {:%N %U}, ignores the tag.

See Also