Skip to content

mp_units::dimensionless

The quantity of dimension one

Synopsis

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

struct dimensionless : mp_units::quantity_spec<derived_quantity_spec<>{}>

Description

A count, such as 3 * one, is of this kind, and a ratio of two quantities of the same kind converts to it. Most quantities of dimension one are its children, such as refractive index or relative permittivity, and they add to each other and to it. With the unit one, they also take a raw number wherever a quantity is expected.

A few are subkinds instead, such as angular measure, solid angular measure, number of entities, and storage capacity. They have dimension one too, but each is a kind of its own, so it doesn't add to or implicitly convert to dimensionless or its children, and it doesn't take a raw number. The unit one measures them too, but 3 * one is a quantity of the kind of dimensionless, so it converts to them only explicitly, as in isq::angular_measure(3 * one):

// the gain of an amplifier, a ratio of two powers
inline constexpr struct power_gain : quantity_spec<dimensionless> {} power_gain;

quantity gain = power_gain(2. * kW / (1. * kW));  // 2
quantity total = gain + 0.5;                      // 2.5, a raw number needs no `* one`
// doesn't compile: an angle is a subkind
// auto bad = gain + 0.5 * rad;

Base Classes

See Also