mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-01 11:24:27 +02:00
docs: imrpove "Superpowers of the unit one
" chapter
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user