Skip to content

mp_units

The quantities and units framework

Description

The part of the library targeted for standardization: quantities, both deltas and points, quantity specifications, dimensions, units, references, and the concepts that constrain them. The systems of quantities and units built with it live in the nested namespaces.

Most code starts from these entities:

  • quantity, a number with a unit and a quantity type, such as 42 * km
  • quantity_point, a point measured from an origin, such as a temperature reading
  • quantity_spec, the base of a quantity type definition, such as length or speed
  • named_unit, the base of a unit definition, such as the metre

Namespaces

NameDescription
angular A system of units that treats angle as a base dimension
astronomy Units commonly used in astronomy beyond the IAU values
cgs The centimetre-gram-second system of units (CGS)
codata The CODATA recommended values of the fundamental physical constants
hep The system of quantities and units of high energy physics (HEP)
iau The constants and units of the International Astronomical Union (IAU)
iec The units of IEC 80000 that are outside the SI
imperial The British imperial system of units
isq The International System of Quantities (ISQ)
isq_angle The ISQ with angle as a base quantity
iupac Units used in chemistry that are outside the SI
natural A system of natural units, where the speed of light and the reduced Planck constant are 1
non_si The non-SI units of the SI Brochure
si The International System of Units (SI)
typographic Typographic units of length
usc The United States customary system of units
utility Tools for authoring representation types and other extensions
yard_pound Units of the international yard and pound of 1959, and related units

Types

NameDescription
absolute_point_origin
base_dimension A dimension of a base quantity
bounds_violation The error returned by quantity_point::try_make for a value that quantity_point::is_within_bounds rejects.
check_in_range Policy that tests whether the value lies between min and max.
check_non_negative Policy that tests whether the value is ≥ 0.
clamp_non_negative Policy that clamps the value to [0, ∞)].
clamp_to_range Policy that clamps the value to [min, max].
common_unit Measurement unit for an accumulation of two quantities of different units
common_unit Measurement unit for an accumulation of two quantities of different units
component_vectors Opts a vector quantity into decomposition into named component vectors
constraint_violation_handler Customization point for handling domain constraint violations.
derived_dimension A dimension of a derived quantity
derived_quantity_spec A specification of a derived quantity
derived_unit Measurement unit for a derived quantity
dimension_one The dimension in which every base dimension has the exponent zero
dimension_symbol_formatting
dimensionless The quantity of dimension one
exclusive_bound Marks a range bound as excluded from the range.
mag_constant
named_constant
named_unit A named unit
no_space_before_unit_symbol Writes a unit's symbol directly after the number, with no space between them
non_negative Marks a quantity that is never negative
one The unit of a quantity of dimension one
parts_per_million Parts per million, a millionth of one
per Type list type storing the list of components with negative exponents
per_mille Per mille, a thousandth of one
percent Percent, a hundredth of one
pi The number π, as a unit
possibly_negative Cancels the non_negative mark a child quantity would inherit from its parent
power Type container for exponents with ratio different than 1
prefixed_unit A prefixed unit
quantity A quantity
quantity_character Quantity character
quantity_like_traits Provides support for external quantity-like types
quantity_point A quantity point
quantity_point_like_traits Provides support for external quantity point-like types
quantity_spec
reference Quantity reference type
reference Quantity reference type
reflect_in_range Policy that reflects (folds) the value at both boundaries.
relative_point_origin
relative_standard_uncertainty Relative standard uncertainty of a measured constant
relative_standard_uncertainty Relative standard uncertainty of a measured constant
representation_canonical_type Customization point: names the type a quantity stores for a value of type T
representation_underlying_type Customization point: names the type that a representation type wraps
representation_values A type trait that defines zero, one, min, and max for a representation type
rounded_down_t The type of rounded_down
rounded_t The type of rounded
rounded_up_t The type of rounded_up
scaled_unit Unit being a scaled version of another unit
standard_uncertainty Absolute standard uncertainty of a measured constant
standard_uncertainty Absolute standard uncertainty of a measured constant
subkind Makes a quantity a kind of its own within the tree of its parent
symbol_text A symbol text representation
truncated_t The type of truncated
unit_symbol_formatting
vector_axes Ordered list of the 1D-vector component axes a vector quantity decomposes into
vector_components [deprecated]The former name of component_vectors
wrap_to_range Policy that wraps the value into the half-open range [min, max)].
zero_t The type of zero

Type Aliases

NameDescription
binomial_distribution [deprecated]The former location of utility::binomial_distribution
cartesian_vector [deprecated]The former location of utility::cartesian_vector
cauchy_distribution [deprecated]The former location of utility::cauchy_distribution
chi_squared_distribution [deprecated]The former location of utility::chi_squared_distribution
discrete_distribution [deprecated]The former location of utility::discrete_distribution
exponential_distribution [deprecated]The former location of utility::exponential_distribution
expr_type
extreme_value_distribution [deprecated]The former location of utility::extreme_value_distribution
fisher_f_distribution [deprecated]The former location of utility::fisher_f_distribution
gamma_distribution [deprecated]The former location of utility::gamma_distribution
geometric_distribution [deprecated]The former location of utility::geometric_distribution
lognormal_distribution [deprecated]The former location of utility::lognormal_distribution
negative_binomial_distribution [deprecated]The former location of utility::negative_binomial_distribution
normal_distribution [deprecated]The former location of utility::normal_distribution
piecewise_constant_distribution [deprecated]The former location of utility::piecewise_constant_distribution
piecewise_linear_distribution [deprecated]The former location of utility::piecewise_linear_distribution
poisson_distribution [deprecated]The former location of utility::poisson_distribution
quantity_values [deprecated]The former name of representation_values
rep_for The representation type of a quantity type, or of a type that quantity_like_traits or quantity_point_like_traits describes
representation_canonical_type_t The type a quantity stores for a value of type T
representation_underlying_type_t The type a representation type wraps, such as double for cartesian_vector<double>
student_t_distribution [deprecated]The former location of utility::student_t_distribution
text_encoding [deprecated]The former name of character_set
uniform_int_distribution [deprecated]The former location of utility::uniform_int_distribution
uniform_real_distribution [deprecated]The former location of utility::uniform_real_distribution
weibull_distribution [deprecated]The former location of utility::weibull_distribution

Enums

NameDescription
character_set Selects the characters a unit or dimension symbol is printed with
quantity_character_legacy [deprecated]The former character of a quantity, now quantity_tensor_order and quantity_field
quantity_field Whether a quantity is real or complex
quantity_tensor_order Whether a quantity is a scalar, a vector, or a tensor
unit_symbol_separator Selects what separates the multiplied units of a unit symbol
unit_symbol_solidus Selects when a unit symbol divides with a solidus and when it uses negative exponents

Functions

NameDescription
abs Computes the absolute value of a quantity
castable [deprecated]
cbrt cbrt overloads
ceil ceil overloads
cubic
default_point_origin
dimension_symbol
dimension_symbol_to
epsilon [deprecated]Returns the epsilon of the quantity
equivalent [deprecated]The former name of utility::equivalent
exp [deprecated]Computes Euler's raised to the given power
explicitly_convertible [deprecated]
floor floor overloads
fma fma overloads
fmod Computes the floating-point remainder of the division operation x / y.
get
get_common_quantity_spec [deprecated]The common quantity specification of the arguments. Use std::common_type_t on two quantities instead.
get_common_reference [deprecated]The common reference of the arguments. Use std::common_type_t on two quantities instead.
get_common_unit [deprecated]The common unit of the arguments. Use std::common_type_t on two quantities instead.
get_dimension
get_kind
get_quantity_spec
get_relative_standard_uncertainty Returns the relative standard uncertainty of a measured constant
get_standard_uncertainty Returns the standard uncertainty of a measured constant
get_unit
hypot hypot overloads
implicitly_convertible [deprecated]
interconvertible [deprecated]
inverse Computes the inverse of a quantity in a provided unit
is_eq_zero [deprecated]
is_gt_zero [deprecated]
is_gteq_zero [deprecated]
is_integral_scaling Returns true if the scaling factor from from to to is an exact positive integer.
is_lt_zero [deprecated]
is_lteq_zero [deprecated]
is_neq_zero [deprecated]
is_non_negative
isfinite isfinite overloads
isinf isinf overloads
isnan isnan overloads
lerp Linear interpolation or extrapolation
midpoint Computes the midpoint of two points
operator% Modulus operators
operator* scaled_unit specializations have priority in this operation. This means that the library framework prevents passing it as an element to the derived_unit. In such case only the reference unit is passed to the derived unit and the magnitude remains outside forming another scaled unit as a result of the operation.
operator+ Addition operators
operator- Subtraction operators
operator/ scaled_unit specializations have priority in this operation. This means that the library framework prevents passing it as an element to the derived_unit. In such case only the reference unit is passed to the derived unit and the magnitude remains outside forming another scaled unit as a result of the operation.
pow pow overloads
quantity_cast quantity_cast overloads
remainder Computes the IEEE remainder of the floating point division operation x / y.
round round overloads
scale [deprecated]The former name of scale_by_magnitude.
scale_by_magnitude scale_by_magnitude overloads
sqrt sqrt overloads
square
to_chrono_duration
to_chrono_time_point
unit_symbol
unit_symbol_to
value_cast value_cast overloads
operator<< Stream insertion operators
operator== Equality operators
operator<=> Three-way comparison operators

Variables

NameDescription
absolute [deprecated]The former name of point
chrono_point_origin The epoch of the std::chrono clock C, as a point origin
delta Creates a delta of reference R from a number
dimension_one The dimension in which every base dimension has the exponent zero
dimensionless The quantity of dimension one
disable_representation Customization point: bars a type from being the representation of any quantity
disable_representation bool holds a truth value rather than a number, so it isn't a representation
disable_representation char holds a character rather than a number, so it isn't a representation
disable_representation char16_t holds a character rather than a number, so it isn't a representation
disable_representation char32_t holds a character rather than a number, so it isn't a representation
disable_representation char8_t holds a character rather than a number, so it isn't a representation
disable_representation wchar_t holds a character rather than a number, so it isn't a representation
disable_representation An empty, trivially constructible and destructible type carries no value, so it isn't a representation
disable_representation A quantity is not the representation of another quantity
disable_representation A quantity point is not the representation of a quantity
frame_projection Customization point: the projection of a point from the absolute origin From to the absolute origin To
imag Customization point object: the imaginary part of a complex value
implicitly_scalable Customization point: whether a conversion between two quantity types is implicit
is_complex [deprecated]No longer used, as the character of a representation type is detected
is_kind [deprecated]The former name of subkind
is_scalar [deprecated]No longer used, as the character of a representation type is detected
is_tensor [deprecated]No longer used, as the character of a representation type is detected
is_value_preserving [deprecated]The former name of implicitly_scalable
is_vector [deprecated]No longer used, as the character of a representation type is detected
kind_of
known_first_factor [deprecated]No longer used, as the library factors magnitudes without a hint
mag The unit magnitude of a number
mag The unit magnitude of a number
mag_pi [deprecated]The former magnitude of π. Multiply by the unit pi instead.
mag_power The unit magnitude of Base raised to the power Num/Den
mag_ratio The unit magnitude of the ratio N/D
magnitude Customization point object: the magnitude of a vector or tensor, as a non-negative scalar
modulus Customization point object: the modulus of a complex scalar
natural_point_origin The natural origin of the quantity QS, its zero
no_space_before_unit_symbol Writes a unit's symbol directly after the number, with no space between them
non_negative Marks a quantity that is never negative
numeric_field Customization point: whether a representation type is real or complex
numeric_field The field detected from the elements of a type whose order is known
one The unit of a quantity of dimension one
parts_per_million Parts per million, a millionth of one
per_mille Per mille, a thousandth of one
percent Percent, a hundredth of one
pi The number π, as a unit
point Creates a point of reference R from a number
possibly_negative Cancels the non_negative mark a child quantity would inherit from its parent
ppm The short name of parts_per_million
real Customization point object: the real part of a complex value
reference_for The reference of a quantity type, or of a type that quantity_like_traits or quantity_point_like_traits describes
rounded Rounding policy that rounds to the nearest value, and to even in halfway cases
rounded_down Rounding policy that rounds towards negative infinity
rounded_up Rounding policy that rounds towards positive infinity
space_before_unit_symbol [deprecated]Whether a space separates a number from the symbol of the unit U in text output
subkind Makes a quantity a kind of its own within the tree of its parent
tensor_order Customization point: the tensor order of a representation type, 0 for a scalar, 1 for a vector, and 2 for a tensor
tensor_order The order detected from the element access of a type that provides at most one indexing shape
treat_as_floating_point Customization point: whether a representation type is treated as floating-point
truncated Rounding policy with the semantics of static_cast and std::chrono::duration_cast
unit_for The unit of a quantity type, or of a type that quantity_like_traits or quantity_point_like_traits describes
zero Zero of any quantity and of any quantity-like type
zeroth_point_origin [deprecated]The former name of natural_point_origin
π The Greek-letter name of pi

Concepts

NameDescription
Dimension A concept matching every dimension
DimensionOf [deprecated]A concept matching a dimension equal to a given one
MeasuredConstant A concept matching constants that are measured rather than exact by definition
PointOrigin [deprecated]A concept matching every point origin
PointOriginFor A concept matching the point origins of a given quantity
PrefixableUnit A concept matching the units that prefixed_unit accepts
Quantity A concept matching every quantity
QuantityOf A concept matching all quantities of the provided property
QuantityPoint A concept matching every quantity point
QuantityPointOf A concept matching the quantity points of a given quantity or origin
QuantitySpec A concept matching every quantity specification
QuantitySpecOf A concept matching the quantity specifications that convert to a given one or admit a given character
Reference A concept matching every reference
ReferenceOf A concept matching the references of a given quantity
RepresentationOf A concept matching the types that can store the numerical value of a given quantity
Unit A concept matching every unit
UnitMagnitude A concept matching every unit magnitude
UnitOf A concept matching the units of a given quantity

See Also