2020-08-17 19:28:47 -04:00
|
|
|
.. namespace:: units
|
|
|
|
|
|
|
|
|
|
Quantity Points
|
|
|
|
|
===============
|
|
|
|
|
|
2020-09-14 08:45:36 +02:00
|
|
|
A quantity point is an absolute quantity with respect to zero
|
2020-08-17 19:28:47 -04:00
|
|
|
(which represents some origin) and is represented in the library with a
|
|
|
|
|
`quantity_point` class template.
|
|
|
|
|
|
|
|
|
|
|
2020-09-14 08:45:36 +02:00
|
|
|
.. _quantity-point-construction:
|
|
|
|
|
|
|
|
|
|
Construction
|
|
|
|
|
------------
|
2020-08-17 19:28:47 -04:00
|
|
|
|
|
|
|
|
To create the quantity point object from a `quantity` we just have to pass
|
|
|
|
|
the value to the `quantity_point` class template explicit constructor::
|
|
|
|
|
|
2020-09-09 19:20:35 +02:00
|
|
|
quantity_point<si::dim_length, si::kilometre, double> d(123_q_km);
|
2020-08-17 19:28:47 -04:00
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
|
|
As the constructor is explicit, the quantity object can be created from
|
|
|
|
|
a quantity only via
|
|
|
|
|
`direct initialization <https://en.cppreference.com/w/cpp/language/direct_initialization>`_.
|
|
|
|
|
This is why the code below using
|
|
|
|
|
`copy initialization <https://en.cppreference.com/w/cpp/language/copy_initialization>`_
|
|
|
|
|
**does not compile**::
|
|
|
|
|
|
2020-09-09 19:20:35 +02:00
|
|
|
quantity_point<si::dim_length, si::kilometre, double> d = 123_q_km; // ERROR
|
2020-08-17 19:28:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Differences to quantity
|
|
|
|
|
-----------------------
|
|
|
|
|
|
2020-09-07 12:44:00 +02:00
|
|
|
Unlike `quantity`, the library provides:
|
|
|
|
|
|
|
|
|
|
- no helper aliases for quantity points, such as ``length_point``,
|
2020-08-17 19:28:47 -04:00
|
|
|
- no UDLs for quantity points,
|
2020-09-07 12:44:00 +02:00
|
|
|
- no dimension-specific concepts, such as ``LengthPoint``
|
2020-08-17 19:28:47 -04:00
|
|
|
(there's the dimension-agnostic `QuantityPoint`),
|
2020-08-17 22:23:11 -04:00
|
|
|
- a more limited set of operations on quantity points
|
2021-01-04 18:36:26 -04:00
|
|
|
(see the :ref:`Dimensions` chapter)
|