mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 20:04: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`
|
### Superpowers of the unit `one`
|
||||||
|
|
||||||
Quantities of the unit `one` are the only ones that are implicitly convertible from a raw value
|
Quantities of the unit `one` are the only ones that are:
|
||||||
and explicitly convertible to it. This property also expands to usual arithmetic operators.
|
|
||||||
|
|
||||||
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
|
```cpp
|
||||||
quantity<one> inc(quantity<one> q) { return q + 1; }
|
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));
|
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
|
## Angular quantities
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user