.. namespace:: units Quantity Kinds ============== A quantity kind is a quantity of more specific usage. It is represented in the library with a `quantity_kind` class template. .. _quantity-point-construction: Kind creation ------------- We need a `kind` to represent the more specific usage of a quantity. struct radius : kind {}; Quantities of kind `radius` represent a radius. They are clearly distinct from more generic usages of length quantities. Construction ------------ To create the quantity kind object from a `quantity` we just have to pass the value to the `quantity_kind` class template constructor:: quantity_kind d(123 * km); .. note:: As the constructor without the kind argument is explicit, the quantity object can be created from a quantity only via `direct initialization `_. This is why the code below using `copy initialization `_ **does not compile**:: quantity_kind d = 123 * km; // ERROR Differences to quantity ----------------------- Unlike `quantity`, the library provides: - no kinds, such as ``radius`` or ``width``, therefore * no UDLs or unit constants, * no kind-specific concepts, such as ``Radius``, (there's the generic `QuantityKind` and kind-specifiable `QuantityKindOf`), - a slightly different set of operations on quantity kinds (see the :ref:`Dimensions` chapter) Quantity point kind ------------------- A quantity point kind is the analogous of a quantity point for quantity kinds. (see the :ref:`Quantity Points` chapter). They are represented in the library with a `quantity_point_kind` class template. First, we need a `point_kind` for a `kind`. struct width : kind {}; struct x_coordinate : point_kind {}; Now x coordinates can be constructed: quantity_point_kind auto x_pos(123 * m); // `QuantityPointKindOf` with `x_pos.relative()` // equal to `quantity_kind(123 * m)`