Custom representation types chapter updated

This commit is contained in:
Mateusz Pusz
2020-03-24 23:30:20 +01:00
parent 781e331ff0
commit 2a5baff160

View File

@@ -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<si::metre, impl<int>> d1(123); // OK
si::length<si::metre, expl<int>> d2(123); // Compile-time error
si::length<si::metre, expl<int>> d3(expl(123)); // OK
si::length<si::metre, impl<int>> d1(123); // OK
si::length<si::metre, expl<int>> d2(123); // Compile-time error
si::length<si::metre, expl<int>> 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<typename T>
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<int> v_impl(1);
expl<int> v_expl(1);
si::length<si::metre, int> d1(v_impl); // OK
si::length<si::metre, int> d2(v_expl); // Compile-time error
si::length<si::metre, int> d3(int(v_expl); // OK
si::length<si::metre, int> d1(v_impl); // OK
si::length<si::metre, int> d2(v_expl); // Compile-time error
si::length<si::metre, int> 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.
:ref:`Linear Algebra of Quantities` chapter and :ref:`measurement` example.