forked from mpusz/mp-units
PrefixType renamed to PrefixFamily + units hierarchy PNG fixed
This commit is contained in:
+11
-11
@@ -97,12 +97,12 @@ All below class templates indirectly derive from a `scaled_unit` class template
|
||||
- Defines a named, in most cases base or coherent unit that is then passed to a dimension's
|
||||
definition.
|
||||
- A named unit may be used by other units defined with the prefix of the same type, unless
|
||||
`no_prefix` is provided for `PrefixType` template parameter (in such a case it is impossible
|
||||
`no_prefix` is provided for `PrefixFamily` template parameter (in such a case it is impossible
|
||||
to define a prefixed unit based on this one).
|
||||
- `named_scaled_unit`
|
||||
- Defines a new named unit that is a scaled version of another unit.
|
||||
- Such unit can be used by other units defined with the prefix of the same type, unless
|
||||
`no_prefix` is provided for `PrefixType` template parameter (in such a case it is impossible
|
||||
`no_prefix` is provided for `PrefixFamily` template parameter (in such a case it is impossible
|
||||
to define a prefixed unit based on this one).
|
||||
- `prefixed_unit`
|
||||
- Defines a new unit that is a scaled version of another unit by the provided prefix.
|
||||
@@ -115,26 +115,26 @@ All below class templates indirectly derive from a `scaled_unit` class template
|
||||
- All of the units provided should also be a named ones so it is possible to create a deduced
|
||||
symbol text.
|
||||
|
||||
Some of the above types depend on `PrefixType` and `no_prefix`. `PrefixType` is a concept that
|
||||
Some of the above types depend on `PrefixFamily` and `no_prefix`. `PrefixFamily` is a concept that
|
||||
is defined as:
|
||||
|
||||
```cpp
|
||||
template<typename T>
|
||||
concept PrefixType = std::derived_from<T, prefix_type>;
|
||||
concept PrefixFamily = std::derived_from<T, prefix_family>;
|
||||
```
|
||||
|
||||
where `prefix_type` is just an empty tag type used to identify the beginning of prefix types
|
||||
where `prefix_family` is just an empty tag type used to identify the beginning of prefix types
|
||||
hierarchy and `no_prefix` is one of its children:
|
||||
|
||||
```cpp
|
||||
struct prefix_type {};
|
||||
struct no_prefix : prefix_type {};
|
||||
struct prefix_family {};
|
||||
struct no_prefix : prefix_family {};
|
||||
```
|
||||
|
||||
Concrete prefix derives from a `prefix` class template:
|
||||
|
||||
```cpp
|
||||
template<typename Child, PrefixType PT, basic_fixed_string Symbol, Ratio R>
|
||||
template<typename Child, PrefixFamily PT, basic_fixed_string Symbol, Ratio R>
|
||||
requires (!std::same_as<PT, no_prefix>)
|
||||
struct prefix;
|
||||
```
|
||||
@@ -151,7 +151,7 @@ Coming back to units, here are a few examples of unit definitions:
|
||||
namespace units::si {
|
||||
|
||||
// prefixes
|
||||
struct prefix : prefix_type {};
|
||||
struct prefix : prefix_family {};
|
||||
struct centi : units::prefix<centi, prefix, "c", ratio<1, 1, -2>> {};
|
||||
struct kilo : units::prefix<kilo, prefix, "k", ratio<1, 1, 3>> {};
|
||||
|
||||
@@ -508,7 +508,7 @@ a series of checks:
|
||||
dimension:
|
||||
- prefix:
|
||||
- if ratio of the scaled unit is `1`, than no prefix is being printed,
|
||||
- otherwise, if `PrefixType` template parameter of a reference unit is different than
|
||||
- otherwise, if `PrefixFamily` template parameter of a reference unit is different than
|
||||
`no_prefix`, and if the ratio of scaled unit matches the ratio of a prefix of a specified
|
||||
type, than the symbol of this prefix will be used,
|
||||
- otherwise, non-standard ratio (i.e. `2 [60]Hz`) will be printed.
|
||||
@@ -781,7 +781,7 @@ adds support for digital information quantities. In summary it adds:
|
||||
```cpp
|
||||
namespace units::data {
|
||||
|
||||
struct prefix : prefix_type {};
|
||||
struct prefix : prefix_family {};
|
||||
|
||||
struct kibi : units::prefix<kibi, prefix, "Ki", ratio< 1'024>> {};
|
||||
struct mebi : units::prefix<mebi, prefix, "Mi", ratio<1'048'576>> {};
|
||||
|
||||
Vendored
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 32 KiB |
@@ -219,7 +219,7 @@ complete list of all the :term:`SI` prefixes supported by the library::
|
||||
|
||||
namespace si {
|
||||
|
||||
struct prefix : prefix_type {};
|
||||
struct prefix : prefix_family {};
|
||||
|
||||
struct yocto : units::prefix<yocto, prefix, "y", ratio<1, 1, -24>> {};
|
||||
struct zepto : units::prefix<zepto, prefix, "z", ratio<1, 1, -21>> {};
|
||||
@@ -249,7 +249,7 @@ domain::
|
||||
|
||||
namespace data {
|
||||
|
||||
struct prefix : prefix_type {};
|
||||
struct prefix : prefix_family {};
|
||||
|
||||
struct kibi : units::prefix<kibi, prefix, "Ki", ratio< 1'024>> {};
|
||||
struct mebi : units::prefix<mebi, prefix, "Mi", ratio< 1'048'576>> {};
|
||||
@@ -322,11 +322,11 @@ of a `scaled_unit` class template:
|
||||
|
||||
#direction: right
|
||||
|
||||
[scaled_unit<Ratio, Unit>]<:-[unit<Child>]
|
||||
[scaled_unit<Ratio, Unit>]<:-[named_unit<Child, Symbol, PrefixType>]
|
||||
[scaled_unit<Ratio, Unit>]<:-[named_scaled_unit<Child, Symbol, PrefixType, Ratio, Unit>]
|
||||
[scaled_unit<Ratio, Unit>]<:-[prefixed_unit<Child, Prefix, Unit>]
|
||||
[scaled_unit<Ratio, Unit>]<:-[deduced_unit<Child, Dimension, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[unit<Child>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[named_unit<Child, Symbol, PrefixFamily>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[named_scaled_unit<Child, Symbol, PrefixFamily, Ratio, Unit>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[prefixed_unit<Child, Prefix, Unit>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[deduced_unit<Child, Dimension, Unit, Unit...>]
|
||||
|
||||
`scaled_unit` is a class template used exclusively by the library's framework
|
||||
and user should not instantiate it by him/her-self. However the user can sometimes
|
||||
|
||||
+28
-17
@@ -5,58 +5,69 @@ Concepts
|
||||
|
||||
.. note::
|
||||
|
||||
All names defined in this chapter reside in the :any:`units` namespace unless specified otherwise.
|
||||
All names defined in this chapter reside in the :any:`units` namespace unless
|
||||
specified otherwise.
|
||||
|
||||
.. concept:: template<typename T> PrefixType
|
||||
.. concept:: template<typename T> PrefixFamily
|
||||
|
||||
Satisfied by all types derived from :class:`prefix_type`.
|
||||
A concept matching a prefix family. Satisfied by all types derived from :class:`prefix_family`.
|
||||
|
||||
.. concept:: template<typename T> Prefix
|
||||
|
||||
Satisfied by all instantiations of :class:`prefix`.
|
||||
A concept matching a symbol prefix. Satisfied by all instantiations of :class:`prefix`.
|
||||
|
||||
.. concept:: template<typename T> Ratio
|
||||
|
||||
Satisfied by all instantiations of :class:`ratio`.
|
||||
A concept matching a ratio. Satisfied by all instantiations of :class:`ratio`.
|
||||
|
||||
.. concept:: template<typename R> UnitRatio
|
||||
|
||||
Satisfied by all types that satisfy :expr:`Ratio<R>` and for which :expr:`R::num > 0` and :expr:`R::den > 0`.
|
||||
A concept matching unit's ratio. Satisfied by all types that satisfy :expr:`Ratio<R>` and
|
||||
for which :expr:`R::num > 0` and :expr:`R::den > 0`.
|
||||
|
||||
.. concept:: template<typename T> BaseDimension
|
||||
|
||||
Satisfied by all dimension types derived from instantiation of :class:`base_dimension`.
|
||||
A concept matching all base dimensions in the library. Satisfied by all dimension types
|
||||
derived from the instantiation of :class:`base_dimension`.
|
||||
|
||||
.. concept:: template<typename T> Exponent
|
||||
|
||||
Satisfied by all instantiations of :class:`exp`.
|
||||
A concept matching dimension's exponents. Satisfied by all instantiations of :class:`exp`.
|
||||
|
||||
.. concept:: template<typename T> DerivedDimension
|
||||
|
||||
Satisfied by all dimension types derived from instantiation of :class:`detail::derived_dimension_base`.
|
||||
A concept matching all derived dimensions in the library. Satisfied by all dimension
|
||||
types derived from the instantiation of :class:`detail::derived_dimension_base`.
|
||||
|
||||
.. concept:: template<typename T> Dimension
|
||||
|
||||
Satisfied by all dimension types for which either :expr:`BaseDimension<T>` or :expr:`DerivedDimension<T>` is ``true``.
|
||||
A concept matching all dimensions in the library. Satisfied by all dimension types for
|
||||
which either :expr:`BaseDimension<T>` or :expr:`DerivedDimension<T>` is ``true``.
|
||||
|
||||
.. concept:: template<typename T> Unit
|
||||
|
||||
Satisfied by all unit types derived from instantiation of :class:`scaled_unit`.
|
||||
A concept matching all unit types in the library. Satisfied by all unit types derived
|
||||
from the instantiation of :class:`scaled_unit`.
|
||||
|
||||
.. concept:: template<typename U, typename D> UnitOf
|
||||
|
||||
Satisfied by all unit types that satisfy :expr:`Unit<U>`, :expr:`Dimension<D>`, and for which
|
||||
:expr:`U::reference` and :expr:`dimension_unit<D>::reference` denote the same unit type.
|
||||
A concept matching only units of a specified dimension. Satisfied by all unit types that
|
||||
satisfy :expr:`Unit<U>`, :expr:`Dimension<D>`, and for which :expr:`U::reference` and
|
||||
:expr:`dimension_unit<D>::reference` denote the same unit type.
|
||||
|
||||
:tparam U: Type to verify against concept constraints.
|
||||
:tparam D: Dimension type to use for verification.
|
||||
|
||||
.. concept:: template<typename T> Quantity
|
||||
|
||||
Satisfied by all instantiations of :class:`quantity`.
|
||||
A concept matching all quantities in the library. Satisfied by all instantiations of :class:`quantity`.
|
||||
|
||||
.. concept:: template<typename T> WrappedQuantity
|
||||
|
||||
Satisfied by all wrapper types that satisfy :expr:`Quantity<typename T::value_type>` recursively
|
||||
(i.e. :expr:`std::optional<si::length<si::metre>>`).
|
||||
A concept matching types that wrap quantity objects. Satisfied by all wrapper types that
|
||||
satisfy :expr:`Quantity<typename T::value_type>` recursively
|
||||
(i.e. :expr:`std::optional<si::length<si::metre>>`).
|
||||
|
||||
.. concept:: template<typename T> Scalar
|
||||
|
||||
Satisfied by types that satisfy :expr:`(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
||||
A concept matching non-Quantity types. Satisfied by types that satisfy :expr:`(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
||||
|
||||
Reference in New Issue
Block a user