docs: imrpove "Superpowers of the unit one" chapter

This commit is contained in:
Mateusz Pusz
2024-09-24 09:02:25 +02:00
parent 488572cbe0
commit 226118852f

View File

@@ -166,10 +166,11 @@ inline constexpr auto ppm = parts_per_million;
### Superpowers of the unit `one`
Quantities of the unit `one` are the only ones that are implicitly convertible from a raw value
and explicitly convertible to it. This property also expands to usual arithmetic operators.
Quantities of the unit `one` are the only ones that are:
Thanks to the above, we can type:
- implicitly constructible from the raw value,
- explicitly convertible to a raw value,
- comparable to a raw value.
```cpp
quantity<one> inc(quantity<one> q) { return q + 1; }
@@ -179,6 +180,14 @@ if (auto q = inc(42); q != 0)
legacy(static_cast<int>(q));
```
This property also expands to usual arithmetic operators.
!!! note
Those rules do not apply to all the dimensionless quantities. It would be unsafe and misleading
to allow such operations on units with a magnitude different than `1` (e.g., `percent` or
`radian`).
## Angular quantities