From 226118852fb52654478723240ad6cc76f7f94606 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 24 Sep 2024 09:02:25 +0200 Subject: [PATCH] docs: imrpove "Superpowers of the unit `one`" chapter --- .../framework_basics/dimensionless_quantities.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/users_guide/framework_basics/dimensionless_quantities.md b/docs/users_guide/framework_basics/dimensionless_quantities.md index 9547aec1..8b4f72e5 100644 --- a/docs/users_guide/framework_basics/dimensionless_quantities.md +++ b/docs/users_guide/framework_basics/dimensionless_quantities.md @@ -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 inc(quantity q) { return q + 1; } @@ -179,6 +180,14 @@ if (auto q = inc(42); q != 0) legacy(static_cast(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