| Document #: | P4185R4 Latest Status |
| Date: | 2026-11-25 |
| Project: | Programming Language C++ |
| Audience: |
SG6 Numerics |
| Reply-to: |
Mateusz Pusz <mateusz.pusz@gmail.com> |
delta<isq::width>[m],
point<isq::altitude, msl>[m]),
points measured from the natural origin of their specification, no
conversion between points of sibling specifications, and no conversion
between quantities of different characters. The vector operations that
compute a scalar from vectors, such as a scalar product, are proposed in
[P4487R0].delta<QS>
is the specification of a delta of
QS, distinct from the plain
QS of an absolute (see The abstraction in the quantity
specification).QS[U]
of a scalar specification is an absolute, and a plain reference of an
offset unit is ill-formed. The plain reference of a vector or tensor
specification names the vector or tensor itself, a delta, as in R2, but
an absolute no longer converts to it, as R2 allowed (see Scalar, vector, and tensor
quantities). A new section, Alternative: an explicit
delta for a vector, compares
this with requiring
delta<QS>
for a vector or tensor.abs(),
hypot(),
magnitude(),
and
modulus(). A
power of a delta is a delta, an even one included, where R2 made an even
power an absolute.
abs() and
hypot() of a
vector specification are ill-formed, as [P4487R0] asks (see Products and quotients of
two deltas).-x of an
absolute is an absolute, as
-1 * x
is, because negation keeps the zero (see Unary negation). R2 made it a delta, for
every absolute or, with [P4411R0], for a
non-negative one. That refinement moved to [P4411R1].quantity_of is implemented in
the prototype, and What generic code
needs reports the cost.R2 proposes absolute quantities, and the title changes from “Completing the Mathematical Model for C++ Quantities and Units” to “Absolute Quantities”. At Brno 2026, SG6 encouraged further work on Section 6 “Absolute quantities” of [P4185R1], and the other chapters moved to papers of their own so that each can be decided separately. The only dependency of this paper is [P3045R10]. Some rules are stated for the case that [P4411R0] is adopted as well.
non_negative
tag on absolute quantities. Absolute quantities no longer depend on the
tag (see Sign of an absolute
quantity).linear_quantity for what absolutes
and deltas share, the common reference of a mixed pair, compound
assignment, the abstraction of
% and
fmod, and the result of
hypot.-5. * m
is a contract violation and a signed value is written
delta<m>(-5.).
A vector value written with a bare unit is ill-formed instead of a
delta.
si::absolute_zero
is the natural origin of thermodynamic temperature, and an offset unit
is a unit whose origin isn’t a natural origin, so the kelvin isn’t one
(see Temperature revisited).quantity_of tells what a quantity
can be used as, and the abstraction concepts tell what it is.quantity<point<R, PO>, Rep>,
as implemented in the unreleased version 3 branch of [mp-units]. Code
examples use the standard_case
concept names of [P3045R10]
(quantity_reference,
point_origin,
quantity_of), and quantity
specifications derive from
named_quantity_spec.quantity_point when its point origin
equals
default_point_origin(R),
resolving the most common case. Points anchored to non-default origins
remain without automatic output.quantity_from_unit_zero()
renamed to
quantity_from_zero(),
with its constraint simplified to
PO == default_point_origin(R).
On a point at its default origin,
.in(unit)
now also switches the point origin to
unit._point_origin_,
consistent with the proposed logarithmic level unit design, so
temp.in(K).quantity_from_zero()
still produces the absolute Kelvin value (see The
temperature trap).[P3045R11] models
quantities with two abstractions, a delta and a point, both written with
the quantity class template:
quantity<R>
is a delta and
quantity<point<R, PO>>
a point. Neither fits the most common value in a physics equation, an
amount measured from a true zero, such as a mass of 5 kg or a
thermodynamic temperature of 300 K. A delta has no zero anchor, and two
points can’t be added, and a point can’t be multiplied or divided.
This paper proposes a third abstraction, the absolute
quantity, anchored at a true zero, and makes it the default
meaning of
quantity<R>.
That is a breaking change to [P3045R11], so SG6 is asked
for a direction before the initial API is fixed. Final wording follows
implementation.
[P3045R11] writes a delta
as
quantity<R>
and a point on a measurement scale, measured from an explicit or
implicit origin, as
quantity<point<R, PO>>.
The two abstractions come from the affine space model: a point minus a
point is a delta, a point plus a delta is a point, and the sum or
product of two points is ill-formed.
Most values in physics and engineering equations are neither. A mass of 5 kg, a duration of 3 s, or a thermodynamic temperature of 300 K is an amount on a ratio scale: it is measured from a true physical zero, so sums, products, and ratios of such values are meaningful, which they are not for points. Unlike a delta, the value is not a difference between two states. With two abstractions, a user has to choose one of them, and neither describes such a value. Motivation and scope shows where that hurts: the rules for temperature units make the ideal gas law hard to write correctly, and a function signature can’t tell a total mass from a mass loss.
The goal is a library where the ideal gas law
quantity R_calc = P * V / (n * T);compiles with T written as
28. * K,
as an absolute thermodynamic temperature, while an offset-scale reading
still has to be converted explicitly, and where
mass and
mass_loss are distinct types the
compiler prevents from being accidentally swapped.
Most code needs only absolute quantities and deltas, since subtracting two absolutes yields a delta. Points stay for offset scales (temperature scales, time zones, reference frames) and for readings relative to a chosen origin.
The three-way split follows the convex-space model of Oliver Rosten [Rosten2025], and it is also implemented, with a different API, in his Sequoia library [Sequoia]. To our knowledge, no mainstream units library in any programming language, including F# Units of Measure, Haskell’s dimensional package, or Python’s Pint, distinguishes absolute quantities, deltas, and points as three separate types.
This section shows two use cases where the lack of a zero-anchored abstraction forces users into awkward workarounds.
A frequently reported usability issue with the current [P3045R11] design involves temperature. The root cause is the interaction between offset units (°C, °F) and the affine space model.
Consider the ideal gas law, . A user might naively attempt:
auto P = 1. * atm;
auto V = 1. * L;
auto n = 1. * mol;
auto T = 28. * deg_C; // ✗ does not compile in P3045!
auto R_calc = P * V / (n * T);This code does not compile under [P3045R11]. Earlier
revisions allowed
28 * deg_C,
until Tiago Freire demonstrated the danger with a concrete ideal gas law
example. The multiply syntax was then disabled for all temperature
units: every temperature unit whose definition names a point origin is
caught by the restriction, and the kelvin was given
absolute_zero as its origin to fall
under the same rule.
The inclusion of Kelvin is necessary for a consistent and safe rule.
The multiply syntax produces a delta, so
28 * K
would not itself construct a point. For Kelvin this causes no direct
harm, but the situation changes entirely if the unit in such an
expression were later changed to an offset unit (e.g.,
deg_C). The result would become a
meaningless delta rather than a compile error. A uniform rule (no
multiply syntax for any temperature unit) is the only way to make the
restriction predictable and refactoring-safe.
The rule is the right fix for the model as it stands, but the model has no way to express “an absolute thermodynamic temperature of 28 K” directly.
Users must explicitly choose between a delta and a point:
auto T1 = delta<K>(28); // a temperature difference of 28 K
auto T2 = point<K>(28.); // 28 K on the Kelvin scale (= 28 K from absolute zero)Neither option correctly captures the intent. By using
delta<K>,
T1 is typed as a delta, a
signed difference between two temperatures, which is semantically
misleading in
,
where 28 K is an absolute thermodynamic temperature, not a difference
between two temperatures. The point
T2 carries the right physical
meaning but cannot be multiplied or divided, as point arithmetic in an
affine space forbids those operations.
The workaround that produces a correct result requires constructing a point measured in Kelvin and extracting the delta from absolute zero:
auto temp = point<deg_C>(28.);
auto T = temp.in(K).delta_from_zero(); // 301.15 K — correct but cumbersome
auto R_calc = P * V / (n * T);The affine space model can handle this case, but the user has to go through a point, convert units, and then extract the delta from zero.
An alternative approach, suggested by Chip Hogg as a “nature-based
constant” idiom, is to subtract
absolute_zero directly from the
point, obtaining the delta from the physical zero:
auto temp = point<deg_C>(28.);
auto T = temp - absolute_zero; // a delta equal to 301.15 K, from absolute zero
auto R_calc = P * V / (n * T);This works even when the point is expressed in
deg_C: the subtraction of the
absolute zero origin yields a delta whose value is the absolute
thermodynamic temperature, and the result can always be scaled to
whatever unit is needed. However, this idiom still requires users to
know that absolute_zero exists,
understand why it must be subtracted, and remember to apply it every
time an absolute temperature is needed.
This problem is not limited to temperature. It affects any domain where absolute quantities (as opposed to differences) are the natural operands in physical equations. The hardware voltage example in the [mp-units] documentation illustrates the same pattern in embedded systems: an ADC maps a physical voltage range to integer counts, and the voltage it reads is an amount measured from 0 V, not a change. Users have independently requested the same ergonomic improvements for such cases (see mp-units discussion #606).
In process engineering, it is common to track the total mass of material in a vessel, then compute a percentage loss:
quantity<percent> moisture_loss(quantity<kg> water_lost, quantity<kg> total)
{
MP_UNITS_EXPECTS(total > 0 * kg);
return water_lost / total;
}Here, water_lost is a difference
(delta) and total is an absolute
amount, but the type system makes no distinction: both are
quantity<kg>.
A user could accidentally swap them:
quantity result = moisture_loss(total_initial, total_initial - total_dried);
// Compiles. Wrong.Defining total_mass and
mass_loss as children of
isq::mass
would prevent the swap, since two siblings convert to each other only
with quantity_cast. But
total_initial - total_dried
then yields a total_mass, and every
correct call site needs a
quantity_cast to
mass_loss.
Both values are masses, possibly measured with the same instrument,
and what differs is their role:
total is a reading anchored at true
zero, and water_lost is the
difference of two such readings. ISO 80000 doesn’t distinguish “total
mass” from “mass loss”, and encoding every such role in the hierarchy
would make every domain grow its own role-based quantities.
If instead the library distinguished absolute quantities (amounts measured from a true zero) from deltas (signed differences), the function signature alone would enforce the correct usage without polluting the quantity hierarchy. The solution is shown in Mass balance revisited.
We propose introducing a third quantity abstraction, the absolute quantity, that sits between deltas and points in the type hierarchy:
Feature
|
Point
|
Absolute
|
Delta
|
|---|---|---|---|
| Multiplication / Division | ✗ | ✓ | ✓ |
| Addition (A + A) | ✗ | ✓ | ✓ |
| Subtraction (A − A) | ✓ | ✓ | ✓ |
| Physical origin | Point origin (explicit or implicit) | Anchored at true zero | N/A |
| Can use offset units | ✓ | ✗ | ✓ |
| Text output | only at the default origin | ✓ | ✓ |
Absolute quantities are anchored at a physically meaningful true zero. They cannot use offset units (because they must remain anchored to absolute zero, not a conventional origin). They may be negative where the physics allows it (see Sign of an absolute quantity).
[ Note: For a quantity that can be negative, an
absolute and a delta share the same mathematical structure: both are
vector spaces with a distinguished zero element. The type distinction
encodes the physical interpretation. An absolute is a ratio-scale
measurement anchored at true physical zero, and a delta of a scalar is a
change with no physical zero anchor. Where the values of a quantity
can’t be negative, its absolutes form a convex cone
[0, +∞),
which is closed under addition but not under negation, and is therefore
not a vector space. — end note ]
This three-way split mirrors the hierarchy found in measurement theory and physics [Rosten2025]:
Concept
|
Measurement Scale
|
Mathematical Structure
|
Physical Meaning
|
|---|---|---|---|
| Point | Interval Scale | Affine Space | A reading relative to an explicit origin (e.g., altitude above sea level, a timestamp) |
| Absolute (any sign permitted) | Ratio Scale | Vector Space (real line); zero = true physical zero | A ratio-scale quantity whose sign is unconstrained (e.g., electric charge, reactive power) |
| Absolute (no negative values) | Ratio Scale | Absolute Convex Space: convex cone with distinguished origin | A non-negative amount; true zero is physically meaningful |
| Delta | — | Vector Space | A change or an interval |
The two absolute rows describe the physics of a quantity. The type of an absolute is the same for both, and this paper doesn’t enforce the sign (see Sign of an absolute quantity).
Points on a scale with a non-trivial lower bound but no
distinguished absolute origin occupy a fourth abstraction in [Rosten2025]:
the convex space, a half-line whose lower bound is
fixed but not zero. The Celsius scale is the canonical example:
ice_point is a
relative_point_origin offset by
273.15 K from
si::absolute_zero,
so the lower bound of 0 K corresponds to −273.15 °C. This paper models
such scales with points, because their values are relative to a chosen
reference.
With absolute quantities as the default, the API becomes:
quantity q1 = 20 * kg; // absolute quantity (measured from true zero)
quantity q2 = delta<kg>(20); // delta quantity (signed difference)
quantity q3 = point<kg>(20); // point quantity (relative to an origin)producing:
static_assert(std::is_same_v<decltype(q1), quantity<kg, int>>);
static_assert(std::is_same_v<decltype(q2), quantity<delta<kg>, int>>);
static_assert(std::is_same_v<decltype(q3), quantity<point<kg>, int>>);This mirrors the way physicists write equations:
denotes an absolute mass, with an explicit
only when a difference is intended. Please note that making
quantity default to absolute is a
breaking change relative to [P3045R11], where
quantity is a delta.
Each abstraction is written the same way for values and for types, with a unit or a quantity specification:
with a unit
|
with a quantity specification
|
|
|---|---|---|
| absolute | 42 * m |
isq::width[m](42) |
| delta | delta<m>(42) |
delta<isq::width>[m](42) |
| point | point<deg_C>(20) |
point<isq::height>[m](42) |
| point from origin | point<m, msl>(42) |
point<isq::altitude, msl>[m](42) |
The types are written the same way:
quantity<isq::width[m]>,
quantity<delta<isq::width>[m]>,
and
quantity<point<isq::altitude, msl>[m]>.
msl stands for a user-defined
origin, the mean sea level, in the examples of this paper.
The multiply syntax,
value * R
and
value / R,
and the call
R(value)
with a plain reference R create what
R names: an absolute for a unit or a
specification of scalar character, and the vector or tensor itself for a
specification of vector or tensor character. They are ill-formed for an
offset unit. A delta is created with
delta<R>(value)
and a point with
point<R>(value),
so
20 * delta<m>
is ill-formed. Multiplying or dividing an absolute or a delta by a unit
keeps its abstraction:
delta<m>(5.) / s
is a delta. A constructor that names the reference, as in
quantity{5., delta<m>},
creates what the reference names.
The plain reference of an offset unit, such as
deg_C, has no absolute and is
ill-formed: it creates no value and names no quantity type. Such a
quantity is always written as a delta or as a point:
delta<deg_C>(5)
and
point<deg_C>(20).
A quantity specification of vector or tensor character has no absolute
either, and its plain reference names the vector or tensor itself:
isq::velocity[m / s](vec)
is a velocity (see Scalar, vector, and
tensor quantities).
A bare unit means an amount.
20 * kg
is an absolute of the quantity kind
kind_of<isq::mass>,
whatever its sign. A signed change of a kind is written as a delta, as
in
delta<m>(-5.)
or
delta<K>(-5.),
and a position on a scale as a point, which picks an origin. If [P4411R1] is adopted,
-5. * K
is a contract violation (see Sign of an
absolute quantity).
In [P3045R11], the abstraction
is a property of the quantity specification.
point<QS>
and
point<QS, PO>
are the specifications of a point, and
delta<QS>
is the specification of a delta. A specification is bound to a unit as
before, as in
delta<isq::width>[m]
and
point<isq::altitude, msl>[m],
and a unit alone is a shorthand:
delta<m>
is
delta<kind_of<isq::length>>[m].
There, a plain
QS[U]
names the same delta as
delta<QS>[U]
for a unit without an offset, and is ill-formed for an offset unit.
This paper changes one thing: a plain specification of scalar
character, such as
isq::height,
or a kind, such as
kind_of<isq::length>,
becomes the specification of an absolute, so
QS[U]
and
delta<QS>[U]
name two different quantities, an amount and a change.
delta<QS>
is the quantity ISO 80000 writes with a Δ, as in ΔT. A specification of
vector or tensor character has no absolute, so its plain form stays the
delta of [P3045R11], and
delta<QS>
names the same specification. An absolute and a delta of
QS are the same node of the quantity
tree, with the same interface, and differ only in their abstraction. The
type of a reference names the unit, not the kind:
delta<m>
is a
delta_<si::metre>,
and
delta<isq::height>[m]
a
delta_<isq::height, si::metre>.
delta<>
takes a plain specification or a unit, as in [P3045R11], and an absolute
isn’t a kind either.
Calling a plain specification with a quantity replaces its
specification and keeps its abstraction:
isq::height(delta<m>(5.))
is a delta of height, the same as
delta<isq::height>(delta<m>(5.)),
and
isq::velocity(delta<m / s>(5.))
is a velocity.
A product or a quotient with a delta operand is the delta of the
result, so
delta<isq::length> / isq::time
is
delta<isq::length / isq::time>,
and so is a power of a delta (see Products and quotients of
two deltas). A point specification has no algebra:
point<isq::length> * isq::time
is ill-formed.
Points can’t simply be given addition and multiplication. A point
lives on an interval scale: timestamps, calendar dates, and
geographic positions can be subtracted, but it makes no sense to add
Tuesday to Friday, or to ask what fraction Berlin is of Paris. An
absolute lives on a ratio scale: it keeps every point
operation, and because all its values share a physically meaningful
zero, sums, products, and ratios of absolutes, such as
T_cold / T_hot
in Carnot efficiency, are meaningful. A point measured from an arbitrary
origin (the floor of a building, the GPS epoch, the freezing point of
water) has no such zero.
For time, a duration has an absolute, and an instant is a point
measured from an epoch, as
std::chrono
measures a time_point from the epoch
of its clock.
Absolute quantities are always scalar: they are ratio-scale magnitudes anchored at a physically meaningful true zero, and the concept of direction, which would require an orientation relative to a reference frame and not just a reference zero, has no place in the model. Vector and tensor quantities live in a vector space. They have a zero (the zero vector or tensor), which may even be a physical one, but not a ratio scale, so they fall in the delta abstraction, unless they are measured from an origin as points. A vector such as a displacement represents a change from a reference. Points carry a concrete origin and may be of any character, depending on the space they inhabit.
Abstraction
|
Scalar
|
Vector
|
Tensor
|
|---|---|---|---|
| Point | point<time>,
point<altitude> |
point<position_vector>,
point<velocity> |
(rare) |
| Delta | delta<duration>,
delta<height> |
displacement,
velocity (always deltas) |
stress
(always a delta) |
| Absolute | duration,
height,
mass |
(none,
magnitude()
gives a scalar absolute) |
(none, as for a vector) |
An unstressed body has zero stress, so a tensor can have a physical
zero. It still isn’t an absolute, because the ratio scale of an absolute
needs a scalar: for a vector or a tensor, the character decides the
abstraction, whatever its zero. Being a delta then means having no
absolute, not necessarily being a change: a displacement is a change of
position, but a stress describes the state of a body and a force an
interaction, and neither is the difference of two states. A stress is
written
isq::stress[Pa](t),
and its norm,
magnitude(),
is an absolute scalar.
A specification of vector or tensor character, such as
isq::velocity,
has no absolute, so its plain reference names the vector or tensor
itself, a delta, and
delta<isq::velocity>[m / s]
is the same reference.
isq::velocity[m / s](vec),
vec * isq::velocity[m / s],
and
quantity<isq::velocity[m / s], vec3>
are velocities, and
point<isq::position_vector>[m](vec)
is a position, while
isq::position_vector[m](vec)
is the vector of that point from the origin, as ISO 80000-3 defines a
position vector. The direction is in the number, and the specification
says that the number may have one, while the unit only measures each
component. A velocity along one axis, stored in a
double, is a
velocity too: in
-9.81 * isq::acceleration[m / s2],
the sign is a direction along an axis of the frame. A scalar
specification in this paper is one of scalar character, whatever the
type of the representation.
An absolute therefore never converts to a vector or tensor
specification, even explicitly:
isq::velocity(5. * m / s),
quantity_cast<isq::velocity>(5. * m / s),
and
quantity<isq::velocity[m / s]> v = 5. * m / s;
are ill-formed:
5. * m / s
is an amount, and an amount has no direction. A velocity is written as
one, as in
isq::velocity[m / s](5.),
or made from a delta, as in
isq::velocity(delta<m / s>(5.)),
or from
q.delta()
of an absolute q meant as a change.
For the same reason,
+,
-,
==, and
< don’t
accept an absolute together with a delta whose common specification is
of vector or tensor character.
The pitfall of this rule is that the same multiply syntax creates a scalar absolute or a vector, and only the specification tells which:
quantity a = 40 * m; // an absolute, a scalar
quantity h = 40 * isq::height[m]; // an absolute, a scalar
quantity d = 40 * isq::displacement[m]; // a vector along one axis, a delta
// quantity<isq::displacement[m]> d2 = a; // ✗ an absolute never converts to a vector
// bool b = (a == d); // ✗ an absolute and a vector don't compareisq::height
is a scalar and
isq::displacement
a vector, and nothing in the spelling shows it. A wrong guess fails to
compile only if it meets a quantity of the other character, as in the
last two lines. If [P4411R1] is adopted, its
sign check also differs:
-40 * m
is a contract violation, while
-40 * isq::displacement[m]
is a vector pointing the other way.
A bare unit such as m,
N, or
m / s names
a quantity kind, and its plain reference is always that of an absolute
of the kind. So
isq::force(5. * N)
is ill-formed. A force is written
isq::force[N](5.),
or
isq::force(delta<N>(5.))
when a delta of the kind already exists. A vector value is never an
absolute of a bare unit:
vec * (m / s)
is ill-formed, while
delta<m / s>(vec)
and
point<m>(vec)
aren’t. A vector result is a delta:
(2. * m) * vec
is a delta. A delta of a vector or tensor specification has no
.absolute(),
and its size is
magnitude(),
an absolute scalar. A component of a vector delta is a delta along an
axis, though its representation is a scalar.
Whether the scalar is real or complex doesn’t decide the abstraction:
a complex scalar (an impedance, a complex power) has a true zero and is
an absolute, and
modulus() of
it is specified as a real absolute.
conj(),
real(), and
imag() keep
the abstraction of their operand: the conjugate or a part of an absolute
is an absolute with the same zero, and that of a delta is a delta.
make_complex()
of two absolutes is an absolute, and of a delta a delta.
The character of a quantity is otherwise the business of [P3045R11]: a quantity
never converts to one of another character, even explicitly, and
magnitude()
gives the scalar of a vector. The scalars the ISQ defines from vectors
or tensors, such as work, are computed with the operations of [P4487R0], such as a scalar
product. This paper adds only the abstraction of their results:
magnitude()
and
modulus()
give an absolute, a vector or tensor result, such as
unit_vector(),
is a delta, and the products follow the rule of Products and quotients of
two deltas.
delta for a vectorThis paper lets the plain reference of a vector or tensor
specification name the vector or tensor itself (option B below). The
alternative makes that reference ill-formed, so a force has to be
written with an explicit delta
(option A). The prototype implements option A.
isq::force[N]
is ill-formed, and a force is written
delta<isq::force>[N](f)
and stored in
quantity<delta<isq::force>[N]>.isq::force[N](f),
f * isq::force[N],
and
quantity<isq::force[N]>
name a force, and
delta<isq::force>[N]
is the same reference as
isq::force[N].delta<QS>
is the quantity ISO 80000 writes with a Δ, a change. A force increment
ΔF, such as a load step, and a strain increment Δε, as in incremental
plasticity, are a force and a strain too, but each is the change of one.
Under option A,
delta<isq::force>
and
delta<isq::strain>
read as ΔF and Δε where F and ε are meant. A scalar needs
delta to tell a change from an
amount, while a vector or a tensor has no absolute, so besides a point,
its delta is the only abstraction it has, and its plain name is
unambiguous.
Option B is the plain-reference rule of [P4185R2] without the
conversion from an absolute that R2 also allowed: there,
isq::velocity(5. * m / s)
turned an absolute into a velocity along one axis. The rules below hold
under both options:
// quantity f = vec{1, 2, 3} * N; // ✗ an absolute of a kind is a scalar
// quantity<m, vec> q; // ✗ an absolute of a kind is a scalar
// quantity f = isq::force(42. * N); // ✗ an absolute never converts to a vector
// quantity<isq::force[N]> f = 42. * N; // ✗ ditto (under option A, isq::force[N] is ill-formed anyway)
quantity d = delta<N>(vec{1, 2, 3}); // a delta of the kind, which has no character yet
quantity F = magnitude(isq::force)(42. * N); // the magnitude of a force, a non-negative absolute
quantity p = point<isq::position_vector>[m](vec{1, 2, 3}); // a position is a point
Criterion
|
Option B (proposed): the plain reference names the
vector
|
Option A: explicit
delta
|
|---|---|---|
| Spelling a force | isq::force[N](f),
f * isq::force[N],
quantity<isq::force[N]> |
delta<isq::force>[N](f),
quantity<delta<isq::force>[N]> |
What
delta<QS>
means |
ΔQS for a scalar. For a vector or a
tensor, the same as QS: a change of
a force is a force, so
isq::force
names both, and delta is needed only
where an amount exists to tell apart from its change: a scalar
specification or a bare unit |
ISO 80000’s ΔQS for a scalar, but required
for a vector itself:
delta<isq::force>
reads as ΔF and
delta<isq::strain>
as Δε, where F and ε are meant |
| What a plain reference names | An absolute for a unit or a scalar specification, the vector or tensor itself otherwise (an offset unit stays ill-formed) | Always an absolute, and ill-formed when there is none |
| The multiply syntax | Creates what the plain reference names:
-9.81 * isq::acceleration[m / s2]
is a 1D vector, and its sign is a direction |
Always creates an absolute |
Reading
40. * isq::X[U] |
Depends on the character of
X
(velocity or
speed,
displacement or
height), and a wrong guess fails to
compile if it reaches a conversion between characters |
The abstraction is visible without knowing
X |
| A vector specification of a position | isq::position_vector[m](v)
is a delta, the vector of a point from the origin, as ISO 80000-3
defines a position vector, and the position itself is
point<isq::position_vector>[m](v) |
point<>
or
delta<>
has to be written:
isq::position_vector[m](v)
is ill-formed |
Generic code on
quantity<QS[U]> |
An absolute or a vector, by the character
of QS. The operations then differ by
character, as they already do for
delta<QS>
under both options |
An absolute, or ill-formed for a vector or
tensor QS |
| Concepts | quantity_of<Q, isq::velocity>
and
quantity_of<Q, delta<isq::velocity>>
are the same, and delta_quantity
holds for
quantity<isq::force[N]> |
quantity_of<Q, isq::velocity>
matches nothing, and a velocity is
quantity_of<Q, delta<isq::velocity>> |
| Types | Two spellings of one type:
delta<QS>
of a vector or tensor QS has to be
the same type as QS, or generic code
sees two |
One spelling per type |
| Code written for [P3045R11] | Vector spellings stay as they are | About 60 spellings of a vector type and 60 vector values changed in the prototype (see Implementation experience) |
| Implementation | The rule of [P4185R2], which also had the conversion from an absolute that both options reject. It isn’t in the current prototype | In the prototype |
In [P3045R11], the quantity specification carries the abstraction, the character, and the origin, and one set of rules decides both whether one specification converts to another and whether a quantity converts: a point never converts to a delta nor the other way round, a quantity never converts to one of another character, and the rules of the hierarchy decide the rest. This paper adds the rules for the absolute abstraction:
.absolute()
does that. An absolute converts to a delta implicitly, only of a
specification of scalar character.quantity<isq::velocity[m / s]> v = delta<m / s>(5.);.
From\To
|
Point
|
Absolute
|
Delta
|
|---|---|---|---|
| Point | Implicit or explicit within one independent origin; point_for(origin) |
.absolute()
(if the origin is a natural origin);otherwise (point - origin_or_qp).absolute() |
point - origin_or_qp;delta_from(origin_or_qp) |
| Absolute | Explicit ctor using natural_point_origin,to a scalar specification |
Identity | Implicit construction to a scalar specification; .delta() |
| Delta | origin + delta → point | Scalar:
.absolute();real scalar: abs();
complex scalar:
modulus();vector: magnitude(),
a scalar absolute |
Identity |
[ Note: The implicit
absolute → delta conversion is
deliberate:
quantity<delta<m>> x = 40 * m;
works without a cast, as an amount is routinely passed where a change is
expected. Its cost is shown in Mass
balance revisited. — end note ]
The following examples demonstrate the explicit and implicit casts between all three abstractions:
// ── From Absolute ──────────────────────────────────────────────────────────────────────
quantity<isq::mass[kg]> total = 5 * kg;
// Absolute → Delta: implicit (no notation at call site) or explicit .delta()
quantity<delta<isq::mass>[kg]> d1 = total; // implicit
quantity<delta<isq::mass>[kg]> d2 = total.delta(); // explicit
// Absolute → Point: explicit construction only (attaches natural_point_origin)
quantity<point<isq::mass>[kg]> p{total}; // explicit ctor
// ── From Delta ─────────────────────────────────────────────────────────────────────────
quantity<delta<isq::mass>[kg]> change = 3 * kg;
// Delta → Absolute: explicit .absolute(), or the magnitude
quantity<isq::mass[kg]> amount = change.absolute();
quantity<isq::mass[kg]> size = abs(change); // |change|
// Delta → Point: origin + delta
quantity<point<isq::length>[m]> pos = natural_point_origin<isq::length> + delta<isq::length>[m](3);
// ── From Point ─────────────────────────────────────────────────────────────────────────
quantity<point<isq::thermodynamic_temperature>[K]> boiling{373.15 * K};
// Point → Delta: subtract a reference origin or another point
quantity<delta<isq::thermodynamic_temperature>[K]> above_zero =
boiling.delta_from(natural_point_origin<isq::thermodynamic_temperature>);
// Point → Absolute: only valid when the point's origin is natural_point_origin
quantity<isq::thermodynamic_temperature[K]> t_abs = boiling.absolute();An absolute may be negative in this paper, so
.absolute()
doesn’t check the value, and a sign check for non-negative quantities is
left to [P4411R1]. The conversion is
still explicit. A delta is a change, and an absolute is an amount
measured from the true zero of its scale. Using one as the other is the
mistake of The temperature trap: a temperature
change of 28 K passed where a temperature of 28 K is needed. An implicit
conversion would let that mistake compile, so
.absolute()
marks the place where a change is used as an amount. The opposite
direction is implicit: an amount is the change from zero to that
amount.
The common reference of an absolute and a delta of a scalar
specification is the delta, the type both of them convert to, which
comparisons such as
5 * kg == delta<kg>(5)
need. get_common_reference means
conversion only, so it coincides with
std::common_type,
and the result of an operator follows the operator’s own rule, so
5 * kg + delta<kg>(5)
is an absolute.
Four concepts tell what a quantity is.
absolute_quantity,
delta_quantity, and
point_quantity each match one
abstraction, and linear_quantity
matches an absolute or a delta. An absolute and a delta share every
operation that doesn’t look at the anchor (scaling, powers, conversions,
text output), and generic code that only needs “not a point” uses
linear_quantity. These concepts are
what overloads and the rules of the model dispatch on.
quantity_of<Q, V>
tells what a quantity can be used as.
V is a quantity specification, and
the concept accepts what a parameter of the corresponding concrete type
accepts, so it follows the rules of Conversions between abstractions:
V
|
quantity_of<Q, V>
matches
|
as a parameter of type
|
|---|---|---|
QS |
absolutes of QS; as
delta<QS>
for a vector or tensor QS |
quantity<QS[U]> |
delta<QS> |
deltas of QS, and absolutes of
QS for a scalar
QS |
quantity<delta<QS>[U]> |
point<QS>
and
point<QS, PO>
match points as in [P3045R11]. A function that
needs an amount, such as
with a thermodynamic temperature, constrains its parameter with
quantity_of<Q, isq::thermodynamic_temperature>,
and a temperature difference is rejected, as it is by a concrete
quantity<isq::thermodynamic_temperature[K]>
parameter. A function that needs a change, such as an average speed from
a distance traveled and an elapsed time, uses
quantity_of<Q, delta<isq::length>>,
and an absolute is accepted, as it would convert to a concrete delta
parameter. A specification of vector or tensor character has no
absolute, so
quantity_of<Q, isq::velocity>
is the same as
quantity_of<Q, delta<isq::velocity>>
and matches velocities. Neither matches an absolute such as
5. * m / s,
which doesn’t convert to a velocity.
delta_quantity<Q>
asks whether Q is a delta, and
quantity_of<Q, delta<QS>>
whether it can be used as one. A template that wants a change and should
accept an absolute uses the latter, or
linear_quantity when the
specification doesn’t matter.
An overload constrained with
quantity_of<Q, QS>
is more constrained than one constrained with
quantity_of<Q, delta<QS>>,
so an absolute argument selects the first and a delta the second. In the
prototype,
quantity_of<Q, delta<QS>>
is written as a disjunction whose first alternative is the constraint of
quantity_of<Q, QS>.
Addition, subtraction, and scaling by a number keep the absolute abstraction whenever the result stays anchored at the true zero of the operands (see the zero-anchor principle). Products and quotients of two absolutes are absolutes, as absolutes live on a ratio scale (see Absolute quantities are not points), and the rule for a delta operand is given in Products and quotients of two deltas.
The following tables give the result abstraction of each operation. The absolute rows and columns of addition and subtraction apply to scalar specifications only (see Scalar, vector, and tensor quantities). Multiplication takes any character: an absolute mass times a vector acceleration is a vector delta.
Lhs \ Rhs
|
Point
|
Absolute
|
Delta
|
|---|---|---|---|
| Point | ✗ | Point | Point |
| Absolute | Point | Absolute | Absolute |
| Delta | Point | Absolute | Delta |
Two absolutes add to an absolute (two masses give a total mass), and
an absolute shifted by a change stays anchored at zero. Adding an
absolute or a delta to an origin yields a point, as in
msl + 100. * m.
quantity tank = isq::mass(500 * kg); // quantity<isq::mass[kg]>
quantity refuel = delta<isq::mass>[kg](200); // quantity<delta<isq::mass>[kg]>: +200 kg (signed change)
quantity loaded = tank + refuel; // quantity<isq::mass[kg]>: 700 kg
tank += refuel; // same: tank is now 700 kg
// To get a signed result instead, explicitly demote before the operation:
quantity balance = tank.delta() + refuel; // quantity<delta<isq::mass>[kg]>
Lhs \ Rhs
|
Point
|
Absolute
|
Delta
|
|---|---|---|---|
| Point | Delta | Point | Point |
| Absolute | ✗ | Delta | Absolute |
| Delta | ✗ | Delta | Delta |
The difference of two absolutes is a signed change, a delta. A delta minus an absolute stays a delta, because a delta has no zero anchor to preserve.
quantity before = isq::mass(100 * kg); // quantity<isq::mass[kg]>
quantity after = isq::mass(80 * kg); // quantity<isq::mass[kg]>
quantity lost = before - after; // quantity<delta<isq::mass>[kg]>: +20 kg (a change)
quantity usage = delta<isq::mass>[kg](20); // quantity<delta<isq::mass>[kg]>: a signed change
quantity remaining = before - usage; // quantity<isq::mass[kg]>: 80 kg
before -= usage; // same: before is now 80 kg
// To get a signed balance, demote first:
quantity deficit = before.delta() - usage; // quantity<delta<isq::mass>[kg]>If an absolute result is needed from an
absolute − absolute subtraction
(e.g., when you know the difference is non-negative), use an explicit
conversion:
quantity transferred = (before - after).absolute(); // quantity<isq::mass[kg]>
Operation
|
Result
|
Physical Meaning
|
|---|---|---|
| Absolute × Absolute | Absolute | A product of two absolute quantities (energy = power × time) |
| Absolute × Number | Absolute | Rescaling by a scalar number, whatever its sign (2 × mass stays absolute mass) |
| Absolute × Delta | Delta | Absolute scaled by a change is a change (e.g., area × Δheight → Δvolume) |
| Delta × Absolute | Delta | (same as Absolute × Delta; multiplication is commutative) |
| Delta × Number | Delta | Rescaling a signed difference (factor preserves delta abstraction) |
| Absolute / Absolute | Absolute | A physical ratio (efficiency, density) |
| Absolute / Delta | Delta | Rate of an absolute w.r.t. a signed step |
| Delta / Absolute | Delta | A change scaled by a fixed absolute reference |
| Delta × Delta | Delta | A product of two changes (see Products and quotients of two deltas) |
| Delta / Delta | Delta | A rate of change (velocity = displacement / duration) |
abs(delta) |
Absolute | Of a real scalar specification; ill-formed for a vector specification |
pow<N>(delta) |
Delta | Any N:
a power doesn’t measure a size, even where it can’t be negative |
modulus(complex_scalar) |
Absolute | Modulus of a complex number |
delta.magnitude() |
Absolute | Magnitude of a vector delta (the magnitude of a velocity is a speed) |
a % b,
fmod(a, b) |
Dividend | The abstraction of the dividend, whose sign the remainder has |
remainder(a, b) |
Delta | The remainder can be negative whatever the signs of the operands |
hypot(x, y) |
Absolute | Of a scalar specification, as for
abs; ill-formed for a vector
specification |
A single delta in a product is a delta by linearity: for a fixed
absolute k,
k * Δy is
the change of
k * y, so a
heat
m * c * ΔT
of a fixed mass is a change. A product or a quotient of two deltas is
not the change of anything.
Δx * Δy is
not the change of a product, and
Δy / Δx is a
slope, measured from its own zero. Whether the two deltas are correlated
decides only the sign of the result, not its abstraction. The rule has
to hold for binary operators, though, and “a delta only with exactly one
delta factor in the numerator” doesn’t, as
(Δa / Δc) * Δb
would be a delta and
(Δa * Δb) / Δc
an absolute. Three alternative rules work for every grouping of the
operands:
.absolute()
after a quotient of deltas.1 / Δt
and a product of three differences a delta.This paper proposes the first rule, which is the one the table above
uses. In the examples of [mp-units], it needs
four
.absolute()
calls, each after a quotient. Three of them follow a quotient of two
signed deltas: a glide distance computed from two altitude differences,
and the durations of an aircraft tow and of a climb in a thermal, each a
height change divided by a rate of climb. Each of these states that the
quotient is non-negative: that the glide line meets the terrain, raised
by the safety height, ahead of the glider, and, for a positive height
gain, that the tow climbs and that the thermal is stronger than the
glider’s sink. If [P4411R1] is adopted, a
negative duration or distance is a contract violation, so the call also
checks it.
abs() would
be wrong in each place, as it would turn a negative result, which is an
error, into a plausible positive one. The fourth, on the gain of a
Kalman filter, goes away when a standard deviation given as an input is
modeled as an absolute, as explained below.
A power follows the same rule:
pow<N>(Δx)
is a delta for every N, as
Δx * Δx is.
An even power can’t be negative, but the sign doesn’t decide the
abstraction, as the zero-anchor
principle explains. Only an operation that measures a size makes an
absolute of a delta:
abs(Δx),
hypot(Δx, Δy),
magnitude()
of a vector, and
modulus() of
a complex scalar.
hypot(x, 0)
equals
abs(x),
and
hypot(x2 - x1, y2 - y1)
is the same distance as
(r2 - r1).magnitude()
for vector positions, so all of them are absolutes. The cost is that
sqrt(pow<2>(Δx) + pow<2>(Δy))
is a delta while
hypot(Δx, Δy)
is an absolute. A variance computed from deltas is a delta, and
.absolute()
states once that it is a size of spread. A standard deviation given as
an input is an absolute, as it is never negative and zero means no
spread, and so are its square and the gain of a Kalman filter, a ratio
of two variances.
A power of a quantity of a vector specification is ill-formed in
[P3045R11], even one stored
in a double,
and [P4487R0] asks that
abs() and
hypot() of
it be ill-formed too: they are scalar operations, and the size of a
vector is its
magnitude().
The square of a velocity along one axis is written
pow<2>(v.magnitude()),
an absolute, because
v.magnitude()
is one.
For the abstraction,
a op= b
follows
a = a op b,
so it is ill-formed when the abstraction of
a op b can’t be stored in
a: an absolute takes no
-= of an
absolute and no
*= or
/= of a
delta. Without that rule,
a -= b would
turn a delta into an absolute without
.absolute().
An absolute quantity is anchored at a true zero, and nothing in this paper constrains its sign. An electric current is positive or negative relative to the reference direction chosen for it, and under the load sign convention a reactive power is positive for an inductive load and negative for a capacitive one, while both have a physically meaningful zero.
Whether a quantity can be negative is stated by the
non_negative tag of [P4411R1], and absolute
quantities are where that paper checks it on values. Which values are
checked, what that means for a negative value written with a bare unit,
such as
-5. * K,
and why some checks can’t be skipped are described in [P4411R1].
-x of an
absolute is an absolute, and
-x of a
delta is a delta. Negation reflects a value around the true zero of its
scale and leaves that zero where it is, so by the zero-anchor principle the result
keeps the abstraction of its operand, as
-1 * x
does. The negation of an electric current is a current flowing the other
way:
quantity<isq::electric_current[A]> I1 = ..., I2 = ...;
quantity<isq::electric_current[A]> I3 = -(I1 + I2); // an absolute current, as Kirchhoff's law needsThe same rule makes
-mass a
negative absolute mass, as
-1 * mass
is. Whether the negation of a quantity that can’t be negative should be
a delta instead depends on the domain of the quantity, which this paper
doesn’t state. [P4411R1] proposes that
refinement.
The rule
Absolute ± Delta → Absolute is the
most visible choice in the arithmetic tables. The initial design of the
library proposed the opposite rule,
Absolute ± Delta → Delta, on the
grounds that any such operation can produce a negative result,
so the type should conservatively demote to the unrestricted delta
space. This section explains why we changed it: the initial reasoning
conflates two orthogonal concerns, the abstraction of a quantity and the
sign constraint on its value.
The result abstraction of
absolute ± delta follows from the
zero-anchor principle: an operation preserves the
absolute abstraction when the result remains anchored at the same
physically meaningful true zero. A delta is a signed change with no
inherent zero anchor. Adding or subtracting a delta from a zero-anchored
quantity does not destroy the zero anchor, as the result is still
measured from the same origin:
mass_tank + Δ_refuel
→ the total mass is still measured from absolute zero (0 kg).mass_tank − Δ_burnt → what
remains is still a mass anchored at zero.This is the rule used for points in affine spaces:
point ± delta → point. Both express
“a translation preserves the abstraction relative to its origin”: the
affine origin for a point, the true zero for an absolute.
The initial design demoted all
absolute ± delta to delta, reasoning
that since a delta can be negative, the result “might” be negative and
the type should conservatively reflect that. This was rejected for two
reasons:
Type demotion is the wrong mechanism for value-range violations.
abs ± delta may be negative at
runtime, but so may abs × number,
and Absolute × Number → Absolute was
never in doubt. Both operations leave the zero anchor where it is, yet
the rejected rule would demote
absolute ± delta but not
absolute × number, although a delta
is a stricter type than a number. Whether a value is in range is a
property of the value, and a check on the value answers it, such as the
one [P4411R1] proposes.
It conflates abstraction with value constraint. Possibly-negative
absolutes like reactive_power belong
on a ratio scale regardless of their sign. Under universal demotion,
reactive_power + delta<reactive_power>
would yield
delta<reactive_power>,
changing the abstraction and making it impossible to store the result
back into a reactive_power variable
without an explicit conversion.
delta > absoluteUnder the adopted rule,
abs - delta
keeps the absolute type, whatever the value. Consider a fuel burn where
the maneuver needs more fuel than the tank holds, with the burn modeled
as a delta:
quantity fuel = isq::mass(500. * kg); // absolute: fuel present in the tank
quantity consumption = delta<isq::mass>[kg](600.); // delta: how much the maneuver burns
fuel -= consumption; // absolute: −100 kgThis paper accepts the −100 kg absolute. If [P4411R1] is adopted, its sign check rejects it, as the prototype does.
The model is the problem. A delta is a change of something, and the
change this maneuver makes to the tank is −600 kg, not +600 kg. The mass
the maneuver burns is an amount: it is measured from zero and can’t be
negative, so it is an absolute, and the change to the tank is minus that
amount. Modeled this way,
abs − abs → delta gives the signed
balance, and code that has to react to a deficit turns it into an amount
only after checking its sign:
quantity fuel = isq::mass(500. * kg); // absolute: fuel present in the tank
quantity consumption = isq::mass(600. * kg); // absolute: mass the maneuver burns
quantity balance = fuel - consumption; // abs − abs → delta<mass>: −100 kg
if (balance < 0 * kg) {
quantity shortfall = abs(balance); // absolute: 100 kg
// handle shortfall: reduce maneuver, add fuel, abort, …
} else {
fuel = balance.absolute(); // the balance is not negative here
}Code that has to keep consumption
a delta gets the same signed balance by demoting first,
fuel.delta() - consumption.
An objection raised in private review (Yongwei Wu) observes that the algebraic identity
does not preserve types. If a,
b,
c are all absolutes, the left-hand
side is
absolute + absolute → absolute,
but the right-hand side
c - b is
absolute − absolute → delta. The
rewritten form
a = c - b
then assigns a delta to an
absolute, which is a type error.
This asymmetry is intrinsic to the three-abstraction model. The rule
absolute − absolute → delta reflects
a physical fact: the difference between two zero-anchored
magnitudes is a signed change, not a new magnitude. For a quantity whose
values can’t be negative this is especially clear (a convex cone is
closed under addition but not under subtraction by definition), but the
asymmetry holds for all absolutes. Even
electric_current − electric_current → delta<electric_current>:
the difference between two current values is a signed change, not a
current level. Removing the asymmetry would require
abs − abs → abs, which labels a
difference as an amount and so would abandon the distinction between
absolute and delta.
// The identity a + b = c does NOT mean c − b has the same type as a:
quantity<isq::mass[kg]> a = 30 * kg; // absolute
quantity<isq::mass[kg]> b = 70 * kg; // absolute
quantity<isq::mass[kg]> c = a + b; // absolute: 100 kg
// quantity<isq::mass[kg]> a2 = c - b; // ✗ delta<mass> ≠ absolute<mass> (type error)
quantity<delta<isq::mass>[kg]> diff = c - b; // delta<mass>: 30 kg — correct delta type
quantity<isq::mass[kg]> a2 = diff.absolute(); // explicit re-entry: 30 kgAn absolute quantity prints like any quantity:
42 * kg
prints
42 kg, the
same text as
delta<kg>(42),
so absolutes need no formatter of their own. The output of points is
discussed in [P3045R11].
With absolute quantities, the temperature use case from The temperature trap is resolved. The key change is in what an offset unit is.
In [P3045R11],
kelvin names
absolute_zero as its point origin,
which triggers the multiply syntax restriction and prevents
28 * K
from compiling. Under the absolute quantities model, an offset
unit is a unit whose point origin is not a natural origin, that
is, doesn’t compare equal to
natural_point_origin<QS>.
The natural origin of a kind marks the same true zero as the natural
origin of a quantity of that kind, so
natural_point_origin<isq::thermodynamic_temperature>
and
natural_point_origin<kind_of<isq::thermodynamic_temperature>>
compare equal.
si::absolute_zero
is the natural origin of thermodynamic temperature under a name of its
own, and kelvin keeps naming it as
its origin, so the kelvin is not an offset unit. The name exists so that
the
temp - absolute_zero
idiom of The temperature trap keeps working and
so that types print a meaningful origin.
ice_point stays a relative origin,
an offset in millikelvin from the kelvin scale, so
degree_Celsius is an offset unit,
and so is degree_Fahrenheit. In the
prototype, natural_point_origin_ is
the class type of
natural_point_origin:
inline constexpr struct absolute_zero : natural_point_origin_<kind_of<isq::thermodynamic_temperature>> {} absolute_zero;
inline constexpr struct kelvin : named_unit<"K", kind_of<isq::thermodynamic_temperature>, absolute_zero> {} kelvin;
// Celsius chain: offset value 273.150 K unchanged
inline constexpr struct ice_point : relative_point_origin<point<milli<kelvin>>(273'150)> {} ice_point;
inline constexpr struct degree_Celsius : named_unit<symbol_text{u8"°C", "`C"}, kelvin, ice_point> {} degree_Celsius;With this definition, a value in kelvins such as
28. * K
is an absolute temperature, and the ideal gas law can be written
directly:
quantity P = 1. * atm;
quantity V = 1. * L;
quantity n = 1. * mol;
quantity T = 301.15 * K; // absolute temperature
quantity R_calc = P * V / (n * T); // compiles, correctWhen working with Celsius input, the conversion path is explicit but straightforward:
// auto T = 28. * deg_C; // still does not compile — offset unit
quantity temp = point<deg_C>(28.); // 28 °C on the Celsius scale
// quantity T = temp.absolute(); // does not compile: the origin is ice_point, not a natural one
quantity T = temp.in(K).absolute(); // 301.15 K — absolute temperature
quantity R_calc = P * V / (n * T); // compiles, correctA point on the Celsius scale is not an absolute temperature, and it
must be converted explicitly.
.in(U)
keeps the plain specification of a point, and a point measured from the
origin of an offset unit moves to the origin of the new unit:
point<deg_C>(28.).in(K)
is a
quantity<point<K>>,
measured from absolute_zero, and
.absolute()
then applies to it. Likewise,
point<isq::thermodynamic_temperature, si::ice_point>[deg_C](20.).in(K)
is a
quantity<point<isq::thermodynamic_temperature>[K]>.
A point measured from any other origin keeps its origin. The
.in(K).absolute()
chain replaces the [P3045R11] workaround
temp.in(K).delta_from_zero().
The lower bound of a Celsius point needs no bounds policy on
ice_point: the chain of
ice_point ends at
absolute_zero, so if [P4411R1] is adopted,
point<deg_C>(-300.)
is a contract violation.
With absolute quantities, the mass balance use case from Mass balance and accumulation gains type-safety through the distinction between absolute and delta:
quantity<delta<percent>> moisture_loss(quantity<delta<kg>> water_lost, quantity<kg> total)
{
return water_lost / total;
}
quantity total_initial = 100 * kg; // absolute mass
quantity total_dried = 80 * kg; // absolute mass
quantity water_lost = total_initial - total_dried; // delta<mass>: +20 kg (difference)
quantity loss = moisture_loss(water_lost, total_initial); // Correct
// Attempting to swap arguments:
// auto loss = moisture_loss(total_initial, water_lost);
// arg1: absolute → delta<kg> param: ✓ compiles — absolute→delta is implicit
// arg2: delta<kg> → absolute param: ✗ fails — delta→absolute requires explicit .absolute()
// The call fails overall, but only because of the second argument.
// A subtler mistake — two absolutes — also compiles:
// auto loss = moisture_loss(total_initial, total_initial);
// arg1: absolute → delta<kg> param: ✓ implicit
// arg2: absolute → absolute param: ✓ identity
// Result: total_initial / total_initial = 1.0 (100%) — wrong answer, no diagnosticThe three-way split is a partial solution to the argument-swapping
problem. It rejects passing a delta where an absolute is required, but
moisture_loss(total_initial, total_initial)
still compiles because the implicit
absolute → delta conversion (see the
conversion note) allows
total_initial to satisfy the
delta<kg>
first parameter. Requiring an explicit
.delta()
call for that conversion would also make the subtler mistake a compile
error, at the cost of a cast wherever an amount is passed as a change.
This paper keeps the conversion implicit, so the residual argument-swap
risk remains in the domain of naming conventions and code review.
At Brno 2026, SG6 asked how to average temperature readings in degrees Celsius and how to compute a center of mass, when two points can’t be added and a point can’t be multiplied by a mass. The textbook formula adds the values first:
using celsius_reading = quantity<point<deg_C>>;
std::array<celsius_reading, 3> readings{point<deg_C>(20.), point<deg_C>(22.5), point<deg_C>(26.)};
quantity avg = (readings[0] + readings[1] + readings[2]) / 3; // ✗ point + point is ill-formedThe same expression compiles for absolute temperatures in kelvins, as absolutes can be added. For Celsius readings it must not compile: the sum of two readings depends on the origin of the scale. 20 °C and 22.5 °C would sum to 42.5 °C on the Celsius scale, but to 588.8 K, which is 315.65 °C, on the Kelvin scale. The mean doesn’t depend on the origin. It can be written with differences only:
Every operation on the right is valid for points: is a delta, a delta divided by a number is a delta, and a point plus a delta is a point. A weighted mean has the same form,
and with masses as weights and positions as points it is the center of mass, computed without multiplying a point by a mass. For two masses, the model already allows writing it by hand:
using vec3 = utility::cartesian_vector<double>; // a vector type of the reference implementation
using position = quantity<point<isq::position_vector>[m], vec3>;
position r1 = point<isq::position_vector>[m](vec3{0., 0., 0.});
position r2 = point<isq::position_vector>[m](vec3{4., 0., 0.});
quantity m1 = 2. * kg;
quantity m2 = 1. * kg;
position center = r1 + (r2 - r1) * (m2 / (m1 + m2)); // [1.333, 0, 0] mThe reference implementation provides both algorithms in its utility
library as
mp_units::utility::mean
and
mp_units::utility::weighted_mean.
They accept ranges of absolutes, deltas, or points, and return the type
of the values:
celsius_reading avg = utility::mean(readings); // 22.83 °C, measured from the ice point
std::array<position, 3> positions{point<isq::position_vector>[m](vec3{0., 0., 0.}),
point<isq::position_vector>[m](vec3{4., 0., 0.}),
point<isq::position_vector>[m](vec3{0., 8., 0.})};
std::array masses{2. * kg, 1. * kg, 1. * kg};
position center = utility::weighted_mean(positions, masses); // [1, 2, 0] mNeither function adds the values up. Every intermediate value is a difference from the first value or from the running mean, so only the spread of the values has to fit in the representation. This also avoids the overflow of the textbook formula for absolutes. The two functions are not proposed in this paper.
This is a breaking change to the initial proposal:
quantity<R>
becomes an absolute quantity instead of a delta.quantity<delta<R>>,
use the
delta<R>(value)
construction helper, or call
.delta()
on an existing absolute quantity.absolute − absolute returns a
delta, not an absolute (the same rule as
point − point → delta). Existing
code that assigns such a result to an
absolute variable will fail to
compile; the fix is either to change the target type to
delta<R>
or to call
.absolute()
on the result to explicitly re-enter the absolute domain.linear_quantity, the concept of
an absolute or a delta, joins the new
absolute_quantity and the
delta_quantity and
point_quantity of [P3045R11]. Generic code
that constrained a parameter with “a delta” to mean “not a point”
migrates to it. For a specification of scalar character,
quantity_of<Q, QS>
matches only absolutes, so a difference or an explicit delta passed
where
quantity_of<Q, QS>
is required now needs
delta<QS>
in the constraint (see Concepts).quantity_like_traits
specialization whose reference is a
bare unit now imports an absolute, so the
std::chrono::duration
specialization names
delta<R>
to stay a delta: the C++ type is a difference, and importing it as an
absolute would make the conversion back to
std::chrono
a refused delta → absolute conversion. So
speed * quantity{std::chrono::seconds{5}}
is a delta distance, and storing it in a
quantity<m>
needs
.absolute().
A time_point stays a point.quantity<isq::velocity[m / s], vec3>
and
vec * isq::velocity[m / s]
stay as they are, and
delta<isq::velocity>
names the same reference. A vector value of a bare unit is created with
delta<m>(vec)
instead of
vec * m.
isq::velocity(5. * m / s),
isq::force(5. * N),
isq::weight(mass * g)
with an absolute mass and an
acceleration g given as an absolute
of its kind become ill-formed.-5. * K
written for a temperature change, is a contract violation, and the
change is written
delta<K>(-5.)
(see [P4411R1]).a -= b with
two absolutes is ill-formed (see Compound
assignment).(x2 - x1) * (y2 - y1)
stored in a
quantity<isq::area[m2]>
needs
.absolute()
(see Products and
quotients of two deltas).remainder(a, b)
of two absolutes returns a delta, while
a % b and
fmod(a, b)
keep the abstraction of the dividend.absolute_point_origin to
independent_point_origin (see Open questions).Code that uses quantity for
absolute amounts (mass, distance, speed) keeps its meaning, because
those are absolute quantities. Code that uses it for signed
differences has to write them as
delta<>.
Absolute quantities are implemented on a prototype branch off the version 3 line of [mp-units] (October 2026). The library, its tests, and its examples build and pass with GCC 15 and Clang 21.
Most of the library changed mechanically. In the tests and the
examples, most changes had one reason: the previous model couldn’t
express what the code meant. An amount and a change were the same type,
so code written for that model had to approximate its intent. With three
abstractions, each of those approximations was replaced by what the code
meant, and some of them turned out to be real errors (see The model finds real errors).
The prototype implements the alternative, an explicit
delta for a vector, and its vector
rules alone changed about 60 spellings of a vector type to
quantity<delta<QS>[U], Rep>,
about 60 values of a vector specification written as
value * QS[U],
9 conversions from an absolute into a vector specification, and 33 point
constructions in the Kalman filter examples. Under the rule this paper
proposes, the first two groups stay as they are in [P3045R11]. The prototype
doesn’t implement that rule yet. A few questions remain open for SG6
(see Open questions).
The rule
absolute − absolute → delta exposed
category errors in the library itself. Five functions stored the
difference of two positions back into a position type:
floor and
ceil,
wrap_to_range and
reflect_in_range, and the canonical
form of a spherical vector.
In the examples it found three modeling errors:
speed, was an absolute, but a
sinking glider has a negative rate of climb, so it is now a delta.Most generic code in the library, and nearly every generic test
helper, needs “an absolute or a delta”, which is to say “not a point”.
This is where linear_quantity comes
from. A survey of the generic code found no place that needs a delta but
must reject an absolute, while about 18 places in the examples need an
amount and about 12 a change that an absolute may stand for. This led to
the meaning of quantity_of described
in Concepts, which the prototype
implements. Of the 64 uses of
quantity_of in the examples of [mp-units], 5, in
three examples, were widened to
delta<QS>,
because a value that means an amount is a delta by type.
The library itself needed a helper to name the return type of 20 functions. An A/B build of two static test files showed no change in compile time beyond the run-to-run spread.
The name of
absolute_point_origin. The
word “absolute” names an abstraction of quantities, and it also names
the origin that starts an independent affine space,
absolute_point_origin, while
si::absolute_zero
is a natural origin. The reference implementation renames the origin and
keeps the old name, deprecated. The candidates are:
absolute_point_origin, the name
used in [P3045R11]: it collides
with the absolute abstraction.independent_point_origin, the
name the reference implementation uses: such an origin starts an affine
space of its own.frame_point_origin: such an
origin defines a frame of reference.root_point_origin and
base_point_origin aren’t candidates,
because “root” names the root of a quantity kind and “base” names base
quantities and units. This paper proposes
independent_point_origin.
quantity class template next to
deltas and points, the default meaning of
quantity<R>,
with a delta spelled
quantity<delta<R>>.delta for a
vector).absolute_point_origin should be
renamed to
independent_point_origin.Special thanks and recognition goes to The C++ Alliance for supporting Mateusz’s membership in the ISO C++ Committee and the production of this proposal.
The author also thanks Oliver Rosten for independently developing the convex-space model [Rosten2025] that contributed the four-space taxonomy and several key design insights used throughout this paper; Tiago Freire for the ideal gas law demonstration that motivated the temperature trap analysis and for detailed ANSI review; Chip Hogg for suggesting the nature-based constant idiom; Yongwei Wu for raising the algebraic identity objection against absolute subtraction; and Amir Kirsh for review feedback.