From 2a5baff160b0cb622ffd474fb12a0b4a6ecf82e1 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 24 Mar 2020 23:30:20 +0100 Subject: [PATCH] Custom representation types chapter updated --- .../use_cases/custom_representation_types.rst | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/docs/use_cases/custom_representation_types.rst b/docs/use_cases/custom_representation_types.rst index 6d45c494..7c02ea1b 100644 --- a/docs/use_cases/custom_representation_types.rst +++ b/docs/use_cases/custom_representation_types.rst @@ -33,9 +33,9 @@ The difference between the above types is that ``impl`` class is implicitly cons from values of type ``T`` while ``expl`` is not. To create quantities using those types as representation types we have to obey similar rules:: - si::length> d1(123); // OK - si::length> d2(123); // Compile-time error - si::length> d3(expl(123)); // OK + si::length> d1(123); // OK + si::length> d2(123); // Compile-time error + si::length> d3(expl(123)); // OK This also applies when we want to create a quantity with a custom representation type from a regular quantity value:: @@ -50,7 +50,10 @@ Conversions of Quantities with Custom Representation Types ---------------------------------------------------------- Again let's assume two types but this time let's scope on converting operators rather -than on constructors:: +than on constructors: + +.. code-block:: + :emphasize-lines: 5, 13 template class impl { @@ -68,13 +71,13 @@ than on constructors:: // the rest of the representation type implementation }; -If we have instances of the above types we can construct quantities in the folLowing way:: +If we have instances of the above types we can construct quantities in the following way:: impl v_impl(1); expl v_expl(1); - si::length d1(v_impl); // OK - si::length d2(v_expl); // Compile-time error - si::length d3(int(v_expl); // OK + si::length d1(v_impl); // OK + si::length d2(v_expl); // Compile-time error + si::length d3(int(v_expl); // OK Similarly, when we have quantities of above types we can create quantities of other representation types with:: @@ -96,4 +99,4 @@ Customization points .. seealso:: For more examples of custom representation types usage please refer to - :ref:`Linear Algebra of Quantities` chapter and `measurement` example. \ No newline at end of file + :ref:`Linear Algebra of Quantities` chapter and :ref:`measurement` example. \ No newline at end of file