From 844bbca3de951c345610a6af1fd655a1aa73e3f0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 3 May 2024 21:37:40 -0400 Subject: [PATCH] xo-unit: doc fixes --- docs/examples.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/examples.rst b/docs/examples.rst index e60de596..b486a494 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -125,7 +125,7 @@ See ``xo-unit/example/ex2`` for code below :emphasize-lines: 1-2 constexpr auto au = q::meter / (q::second * q::second); /* just for units */ - constexpr auto a3 = with_units(a, au); + constexpr auto a3 = with_units_from(a, au); /* a, but with units from au */ static_assert(a3.abbrev() == flatstring("m.s^-2")); @@ -138,16 +138,18 @@ with output: a3: 0.173611m.s^-2 -Scale conversion triggered by assignment ----------------------------------------- +Implicit Scale conversion triggered by assignment +------------------------------------------------- -Another way to convert units is by assignment +Another way to convert units is to assign to a variable +with desired units -- this works because the units are encoded +as part of the assigned variable's type. See ``xo-unit/example/ex3`` for code below .. code-block:: cpp :linenos: - :emphasize-lines: 10-11 + :emphasize-lines: 11-12 int main () { @@ -179,8 +181,8 @@ with output: Remarks: * Assignment to ``t`` converted to representation ``double``. - We could have used :code:`quantity` to convert (possibly rounding down) - representation to `int`. + We could have used :code:`stdquantity` to preserve + right-hand-side representation. Scale conversion triggered by arithmetic ----------------------------------------