mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-03 12:24:26 +02:00
refactor: *deduced_unit
renamed to *derived_unit
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
- (!) refactor: Refactored the library file tree
|
||||
- (!) refactor: `quantity::count()` renamed to `quantity::number()`
|
||||
- (!) refactor: `data` system renamed to `isq::iec80000` (quantity names renamed too)
|
||||
- (!) refactor: `*deduced_unit` renamed to `*derived_unit`
|
||||
- refactor: quantity (kind) point updated to reflect latest changes to `quantity`
|
||||
- refactor: basic concepts, `quantity` and `quantity_cast` refactored
|
||||
- refactor: `abs()` definition refactored to be more explicit about the return type
|
||||
|
@@ -8,7 +8,7 @@ compare quantities of the same dimension a notion of a :term:`measurement unit`
|
||||
was introduced. Units are designated by conventionally assigned names and
|
||||
symbols. Thanks to them it is possible to compare two quantities of the
|
||||
same dimension and express the ratio of the second quantity to the first
|
||||
one as a number. For example ``10s`` is ``10`` times more than ``1s``.
|
||||
one as a number. For example ``10 s`` is ``10`` times more than ``1 s``.
|
||||
|
||||
Base quantities are expressed in terms of :term:`base units <base unit>`
|
||||
(i.e. ``m`` (meter), ``s`` (second)), while derived quantities are expressed
|
||||
@@ -94,97 +94,14 @@ knows how to convert ``si::metre`` to ``si::centimetre`` and vice versa).
|
||||
:ref:`use_cases/extensions:Custom Systems` chapter.
|
||||
|
||||
|
||||
Derived Units
|
||||
-------------
|
||||
|
||||
Derived units can be either named or unnamed.
|
||||
|
||||
Derived Named Units
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Derived named units have a unique symbol (i.e. ``N`` (newton) or ``Pa``
|
||||
(pascal)) and they are defined in the same way as base units (which
|
||||
always have to be a named unit)::
|
||||
|
||||
namespace si {
|
||||
|
||||
struct newton : named_unit<newton, "N", prefix> {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
Derived Unnamed Units
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Derived unnamed units are the units where the symbol is derived from the
|
||||
base quantities symbols and the expression of the dependence of the derived
|
||||
quantity on the base quantities (i.e. ``m/s`` (metre per second), ``m²``
|
||||
(square metre)). To support such use cases a library introduced a notion of
|
||||
:term:`derived dimension recipe` which stores the information about the
|
||||
order, exponents, and types of dimensions used to defined this particular
|
||||
derived dimension. For example each of the below ``momentum`` definitions
|
||||
will result in a different unnamed unit symbol:
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 2-4, 6-8, 10-12
|
||||
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // kg ⋅ m/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // m ⋅ kg/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_time, -1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>> {}; // 1/s ⋅ m ⋅ kg
|
||||
|
||||
where ``kilogram_metre_per_second`` is defined as::
|
||||
|
||||
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
|
||||
|
||||
However, the easiest way to define momentum is just to use the
|
||||
``si::dim_speed`` derived dimension in the recipe:
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 3
|
||||
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_speed, 1>> {}; // kg ⋅ m/s
|
||||
|
||||
In such a case the library will do its magic and will automatically
|
||||
unpack a provided derived dimension to its base dimensions in order to
|
||||
end up with a :term:`normalized derived dimension` for a parent entity.
|
||||
|
||||
|
||||
The need to support a derived dimension in the recipe is not just a
|
||||
syntactic sugar that allows us to do less typing. It is worth to notice
|
||||
here that some of the derived unnamed units are defined in terms of other
|
||||
derived named units (i.e. surface tension quantity is measured in terms
|
||||
of ``N/m``):
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 2
|
||||
|
||||
struct dim_surface_tension : derived_dimension<dim_surface_tension, newton_per_metre,
|
||||
exponent<si::dim_force, 1>,
|
||||
exponent<si::dim_length, -1>> {}; // N/m
|
||||
|
||||
If we defined the above in terms of base units we would end up with
|
||||
a ``kg/s²`` derived unit symbol.
|
||||
|
||||
|
||||
Scaled Units
|
||||
------------
|
||||
|
||||
Until now we talked mostly about
|
||||
:term:`coherent units <coherent derived unit>` which are units used to
|
||||
define dimensions and thus, in their system of units, have proportionality
|
||||
factor/ratio equals one. However quantities of each dimension can also use
|
||||
other units of measurement to describe their magnitude (numerical value).
|
||||
Described above base units (in case of base quantities) and
|
||||
:term:`coherent units <coherent derived unit>` (in case of derived quantities),
|
||||
in their system of units, have proportionality factor/ratio equal to one.
|
||||
However, quantities of such dimensions can also use units of measurement
|
||||
with other ratios to describe their magnitude (numerical value).
|
||||
|
||||
|
||||
Named Scaled Units
|
||||
@@ -289,13 +206,99 @@ example we can define ``si::kilometre`` as::
|
||||
as ``km²`` would be invalid).
|
||||
|
||||
|
||||
Deduced Units
|
||||
^^^^^^^^^^^^^
|
||||
Derived Units
|
||||
-------------
|
||||
|
||||
:term:`Derived units <derived unit>` are the units used to measure
|
||||
:term:`derived quantities <derived quantity>`. They can either have their own unique
|
||||
names (i.e. ``N`` (newton)) or can be composed from the names of units of quantities
|
||||
used to define thier derived quantity (i.e. ``km/h``).
|
||||
|
||||
|
||||
Derived Named Units
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Derived named units have a unique symbol (i.e. ``N`` (newton) or ``Pa``
|
||||
(pascal)) and they are defined in the same way as base units (which
|
||||
always have to be a named unit)::
|
||||
|
||||
namespace si {
|
||||
|
||||
struct newton : named_unit<newton, "N", prefix> {};
|
||||
|
||||
}
|
||||
|
||||
|
||||
Derived Unnamed Units
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Derived unnamed units are the units where the symbol is derived from the
|
||||
base quantities symbols and the expression of the dependence of the derived
|
||||
quantity on the base quantities (i.e. ``m/s`` (metre per second), ``m²``
|
||||
(square metre)). To support such use cases a library introduced a notion of
|
||||
:term:`derived dimension recipe` which stores the information about the
|
||||
order, exponents, and types of dimensions used to define this particular
|
||||
derived dimension. For example each of the below ``momentum`` definitions
|
||||
will result in a different unnamed unit symbol:
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 2-4, 6-8, 10-12
|
||||
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // kg ⋅ m/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_time, -1>> {}; // m ⋅ kg/s
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_time, -1>,
|
||||
exponent<si::dim_length, 1>,
|
||||
exponent<si::dim_mass, 1>> {}; // 1/s ⋅ m ⋅ kg
|
||||
|
||||
where ``kilogram_metre_per_second`` is defined as::
|
||||
|
||||
struct kilogram_metre_per_second : unit<kilogram_metre_per_second> {};
|
||||
|
||||
However, the easiest way to define momentum is just to use the
|
||||
``si::dim_speed`` derived dimension in the recipe:
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 3
|
||||
|
||||
struct dim_momentum : derived_dimension<dim_momentum, kilogram_metre_per_second,
|
||||
exponent<si::dim_mass, 1>,
|
||||
exponent<si::dim_speed, 1>> {}; // kg ⋅ m/s
|
||||
|
||||
In such a case the library will do its magic and will automatically
|
||||
unpack a provided derived dimension to its base dimensions in order to
|
||||
end up with a :term:`normalized derived dimension` for a parent entity.
|
||||
|
||||
The need to support a derived dimension in the recipe is not just a
|
||||
syntactic sugar that allows us to do less typing. It is worth to notice
|
||||
here that some of the derived unnamed units are defined in terms of other
|
||||
derived named units (i.e. surface tension quantity is measured in terms
|
||||
of ``N/m``):
|
||||
|
||||
.. code-block::
|
||||
:emphasize-lines: 2
|
||||
|
||||
struct dim_surface_tension : derived_dimension<dim_surface_tension, newton_per_metre,
|
||||
exponent<si::dim_force, 1>,
|
||||
exponent<si::dim_length, -1>> {}; // N/m
|
||||
|
||||
If we defined the above in terms of base units we would end up with
|
||||
a ``kg/s²`` derived unit symbol.
|
||||
|
||||
|
||||
Derived Scaled Units
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
For some units determining of a correct scaling ratio may not be trivial,
|
||||
and even if done correctly, may be a pain to maintain. For a simple example
|
||||
let's take a "kilometre per hour" unit. What is the easiest to maintain
|
||||
ratio in reference to "metre per second":
|
||||
ratio in reference to the "metre per second":
|
||||
|
||||
- ``1000/3600``
|
||||
- ``10/36``
|
||||
@@ -303,30 +306,29 @@ ratio in reference to "metre per second":
|
||||
|
||||
Whichever, we choose there will always be someone not happy with our choice.
|
||||
|
||||
Thanks to a `deduced_unit` class template provided by the library this problem
|
||||
Thanks to a `derived_unit` class template provided by the library this problem
|
||||
does not exist at all. With it ``si::kilometre_per_hour`` can be defined as::
|
||||
|
||||
namespace si {
|
||||
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
|
||||
}
|
||||
|
||||
In case the deduced unit should served as a named one we can use ether a
|
||||
`named_deduced_unit` where the user is able to provide a symbol for the unit
|
||||
by him/her-self or `noble_deduced_unit` where the symbol is the deduced name
|
||||
In case the scaled derived unit should serve as a named one we can use either
|
||||
a `named_derived_unit` where the user is able to provide a symbol for the unit
|
||||
by him/her-self or `noble_derived_unit` where the symbol is the deduced name
|
||||
based on the ingredients::
|
||||
|
||||
namespace si::fps {
|
||||
|
||||
struct nautical_mile_per_hour : named_deduced_unit<nautical_mile_per_hour, dim_speed,
|
||||
"knot", no_prefix, nautical_mile, hour>{};
|
||||
struct foot_pound_force : noble_deduced_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
struct knot : named_derived_unit<knot, dim_speed, "knot", no_prefix, nautical_mile, hour> {};
|
||||
struct foot_pound_force : noble_derived_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
|
||||
}
|
||||
|
||||
Please note that deduced units are the only unit-related class template that
|
||||
take a dimension as its parameter. This derived dimension provides a :term:`recipe`
|
||||
Please note that the dervided scaled units are the only unit-related class templates
|
||||
that take a dimension as its parameter. This derived dimension provides a :term:`recipe`
|
||||
used for its definition. Based on the information stored in the recipe
|
||||
(order, type, and exponents of composite dimensions) and the ratios of units
|
||||
provided in the template parameter list after the derived dimension parameter,
|
||||
@@ -377,9 +379,9 @@ of a `scaled_unit` class template:
|
||||
[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<UnitRatio, Unit>]<:-[noble_deduced_unit<Child, Dimension, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[named_deduced_unit<Child, Dimension, Symbol, PrefixFamily, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[derived_unit<Child, Dimension, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[noble_derived_unit<Child, Dimension, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[named_derived_unit<Child, Dimension, Symbol, PrefixFamily, Unit, Unit...>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[alias_unit<Unit, Symbol, PrefixFamily>]
|
||||
[scaled_unit<UnitRatio, Unit>]<:-[prefixed_alias_unit<Unit, Prefix, AliasUnit>]
|
||||
|
||||
|
@@ -16,13 +16,13 @@ Units
|
||||
.. doxygenstruct:: units::prefixed_unit
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: units::deduced_unit
|
||||
.. doxygenstruct:: units::derived_unit
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: units::noble_deduced_unit
|
||||
.. doxygenstruct:: units::noble_derived_unit
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: units::named_deduced_unit
|
||||
.. doxygenstruct:: units::named_derived_unit
|
||||
:members:
|
||||
|
||||
.. doxygenstruct:: units::alias_unit
|
||||
|
@@ -118,7 +118,7 @@ coherent unit::
|
||||
exponent<si::dim_area, 1>, exponent<si::dim_time, -1>> {};
|
||||
|
||||
// our unit of interest for a new derived dimension
|
||||
struct desk_per_hour : deduced_unit<desk_per_hour, dim_desk_rate, desk, si::hour> {};
|
||||
struct desk_per_hour : derived_unit<desk_per_hour, dim_desk_rate, desk, si::hour> {};
|
||||
|
||||
// a quantity of our dimension
|
||||
template<UnitOf<dim_desk_rate> U, Representation Rep = double>
|
||||
@@ -167,7 +167,7 @@ With the above we can now define a new derived dimension::
|
||||
exponent<dim_people, 1>,
|
||||
exponent<si::dim_area, -1>> {};
|
||||
|
||||
struct person_per_desk : deduced_unit<person_per_desk, dim_occupancy_rate, person, desk> {};
|
||||
struct person_per_desk : derived_unit<person_per_desk, dim_occupancy_rate, person, desk> {};
|
||||
|
||||
template<UnitOf<dim_occupancy_rate> U, Representation Rep = double>
|
||||
using occupancy_rate = quantity<dim_occupancy_rate, U, Rep>;
|
||||
|
@@ -80,16 +80,16 @@ template<typename... Es>
|
||||
inline constexpr int negative_exp_count = ((Es::num < 0 ? 1 : 0) + ... + 0);
|
||||
|
||||
template<typename... Us, typename... Es, std::size_t... Idxs>
|
||||
constexpr auto deduced_symbol_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
constexpr auto derived_symbol_text(exponent_list<Es...>, std::index_sequence<Idxs...>)
|
||||
{
|
||||
constexpr auto neg_exp = negative_exp_count<Es...>;
|
||||
return (exp_text<Es, Us::symbol, neg_exp, Idxs>() + ...);
|
||||
}
|
||||
|
||||
template<DerivedDimension Dim, Unit... Us>
|
||||
constexpr auto deduced_symbol_text()
|
||||
constexpr auto derived_symbol_text()
|
||||
{
|
||||
return deduced_symbol_text<Us...>(typename Dim::recipe(), std::index_sequence_for<Us...>());
|
||||
return derived_symbol_text<Us...>(typename Dim::recipe(), std::index_sequence_for<Us...>());
|
||||
}
|
||||
|
||||
} // namespace units::detail
|
@@ -33,7 +33,7 @@ inline constexpr bool same_scaled_units = false;
|
||||
template<typename... Es, Unit... Us>
|
||||
inline constexpr bool same_scaled_units<exponent_list<Es...>, Us...> = (UnitOf<Us, typename Es::dimension> && ...);
|
||||
|
||||
// deduced_unit
|
||||
// derived_unit
|
||||
|
||||
template<Exponent E>
|
||||
constexpr ratio inverse_if_negative(const ratio& r)
|
||||
@@ -51,6 +51,6 @@ constexpr ratio derived_ratio(exponent_list<Es...>)
|
||||
}
|
||||
|
||||
template<DerivedDimension D, Unit... Us>
|
||||
using deduced_unit = scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
|
||||
using derived_unit = scaled_unit<derived_ratio<Us...>(typename D::recipe()), typename D::coherent_unit::reference>;
|
||||
|
||||
} // namespace units::detail
|
@@ -22,7 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/deduced_symbol_text.h>
|
||||
#include <units/bits/derived_symbol_text.h>
|
||||
#include <units/bits/external/text_tools.h>
|
||||
#include <units/prefix.h>
|
||||
#include <units/derived_dimension.h>
|
||||
|
@@ -22,11 +22,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <units/bits/deduced_symbol_text.h>
|
||||
#include <units/bits/derived_symbol_text.h>
|
||||
#include <units/bits/external/downcasting.h>
|
||||
|
||||
// IWYU pragma: begin_exports
|
||||
#include <units/bits/deduced_unit.h>
|
||||
#include <units/bits/derived_unit.h>
|
||||
#include <units/bits/external/fixed_string.h>
|
||||
#include <units/prefix.h>
|
||||
#include <units/ratio.h>
|
||||
@@ -155,9 +155,9 @@ struct prefixed_unit : downcast_dispatch<Child, scaled_unit<P::ratio * U::ratio,
|
||||
template<typename Child, DerivedDimension Dim, Unit U, Unit... URest>
|
||||
requires detail::same_scaled_units<typename Dim::recipe, U, URest...> &&
|
||||
(U::is_named && (URest::is_named && ... && true))
|
||||
struct deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = false;
|
||||
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
|
||||
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
|
||||
using prefix_family = no_prefix;
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ struct deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URes
|
||||
*
|
||||
* Defines a new unit with a deduced ratio and symbol based on the recipe from the provided
|
||||
* derived dimension. The number and order of provided units should match the recipe of the
|
||||
* derived dimension. All of the units provided should also be a named ones so it is possible
|
||||
* derived dimension. All of the units provided should also be named ones so it is possible
|
||||
* to create a deduced symbol text.
|
||||
*
|
||||
* @tparam Child inherited class type used by the downcasting facility (CRTP Idiom)
|
||||
@@ -179,9 +179,9 @@ template<typename Child, DerivedDimension Dim, Unit U, Unit... URest>
|
||||
requires detail::same_scaled_units<typename Dim::recipe, U, URest...> &&
|
||||
(U::is_named && (URest::is_named && ... && true))
|
||||
// TODO - 'noble' is placeholder to sort of mean can pass its name on to other deduced units
|
||||
struct noble_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct noble_derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = true;
|
||||
static constexpr auto symbol = detail::deduced_symbol_text<Dim, U, URest...>();
|
||||
static constexpr auto symbol = detail::derived_symbol_text<Dim, U, URest...>();
|
||||
using prefix_family = no_prefix;
|
||||
};
|
||||
|
||||
@@ -203,7 +203,7 @@ struct noble_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U
|
||||
*/
|
||||
template<typename Child, DerivedDimension Dim, basic_symbol_text Symbol, PrefixFamily PF, Unit U, Unit... URest>
|
||||
requires detail::same_scaled_units<typename Dim::recipe, U, URest...>
|
||||
struct named_deduced_unit : downcast_dispatch<Child, detail::deduced_unit<Dim, U, URest...>> {
|
||||
struct named_derived_unit : downcast_dispatch<Child, detail::derived_unit<Dim, U, URest...>> {
|
||||
static constexpr bool is_named = true;
|
||||
static constexpr auto symbol = Symbol;
|
||||
using prefix_family = PF;
|
||||
|
@@ -37,14 +37,14 @@ namespace units::isq::iec80000 {
|
||||
struct byte_per_second : unit<byte_per_second> {};
|
||||
struct dim_transfer_rate : derived_dimension<dim_transfer_rate, byte_per_second, exponent<dim_storage_capacity, 1>, exponent<si::dim_time, -1>> {};
|
||||
|
||||
struct kilobyte_per_second : deduced_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
|
||||
struct megabyte_per_second : deduced_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
|
||||
struct gigabyte_per_second : deduced_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
|
||||
struct terabyte_per_second : deduced_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
|
||||
struct petabyte_per_second : deduced_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
|
||||
struct exabyte_per_second : deduced_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
|
||||
struct zettabyte_per_second : deduced_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
|
||||
struct yottabyte_per_second : deduced_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
|
||||
struct kilobyte_per_second : derived_unit<kilobyte_per_second, dim_transfer_rate, kilobyte, si::second> {};
|
||||
struct megabyte_per_second : derived_unit<megabyte_per_second, dim_transfer_rate, megabyte, si::second> {};
|
||||
struct gigabyte_per_second : derived_unit<gigabyte_per_second, dim_transfer_rate, gigabyte, si::second> {};
|
||||
struct terabyte_per_second : derived_unit<terabyte_per_second, dim_transfer_rate, terabyte, si::second> {};
|
||||
struct petabyte_per_second : derived_unit<petabyte_per_second, dim_transfer_rate, petabyte, si::second> {};
|
||||
struct exabyte_per_second : derived_unit<exabyte_per_second, dim_transfer_rate, exabyte, si::second> {};
|
||||
struct zettabyte_per_second : derived_unit<zettabyte_per_second, dim_transfer_rate, zettabyte, si::second> {};
|
||||
struct yottabyte_per_second : derived_unit<yottabyte_per_second, dim_transfer_rate, yottabyte, si::second> {};
|
||||
|
||||
template<typename T>
|
||||
concept TransferRate = QuantityOf<T, dim_transfer_rate>;
|
||||
|
@@ -40,7 +40,7 @@ struct foot_poundal : unit<foot_poundal> {};
|
||||
struct dim_energy : isq::dim_energy<dim_energy, foot_poundal, dim_force, dim_length> {};
|
||||
|
||||
// https://en.wikipedia.org/wiki/Foot-pound_(energy)
|
||||
struct foot_pound_force : noble_deduced_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
struct foot_pound_force : noble_derived_unit<foot_pound_force, dim_energy, pound_force, foot> {};
|
||||
|
||||
template<UnitOf<dim_energy> U, Representation Rep = double>
|
||||
using energy = quantity<dim_energy, U, Rep>;
|
||||
|
@@ -39,7 +39,7 @@ struct foot_poundal_per_second : unit<foot_poundal_per_second> {};
|
||||
|
||||
struct dim_power : isq::dim_power<dim_power, foot_poundal_per_second, dim_energy, dim_time> {};
|
||||
|
||||
struct foot_pound_force_per_second : deduced_unit<foot_pound_force_per_second, dim_power, foot_pound_force, second> {};
|
||||
struct foot_pound_force_per_second : derived_unit<foot_pound_force_per_second, dim_power, foot_pound_force, second> {};
|
||||
|
||||
struct horse_power : named_scaled_unit<horse_power, "hp", no_prefix, ratio(550), foot_pound_force_per_second> {};
|
||||
|
||||
|
@@ -41,10 +41,8 @@ struct dim_speed : isq::dim_speed<dim_speed, foot_per_second, dim_length, dim_ti
|
||||
template<UnitOf<dim_speed> U, Representation Rep = double>
|
||||
using speed = quantity<dim_speed, U, Rep>;
|
||||
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, dim_speed, mile, hour>{};
|
||||
|
||||
struct nautical_mile_per_hour : named_deduced_unit<nautical_mile_per_hour, dim_speed, "knot", no_prefix, nautical_mile, hour>{};
|
||||
|
||||
struct mile_per_hour : derived_unit<mile_per_hour, dim_speed, mile, hour>{};
|
||||
struct nautical_mile_per_hour : derived_unit<nautical_mile_per_hour, dim_speed, nautical_mile, hour>{};
|
||||
struct knot : alias_unit<nautical_mile_per_hour, "knot", no_prefix> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
@@ -37,7 +37,7 @@ namespace units::isq::si::fps {
|
||||
struct cubic_foot : unit<cubic_foot> {};
|
||||
struct dim_volume : isq::dim_volume<dim_volume, cubic_foot, dim_length> {};
|
||||
|
||||
struct cubic_yard : deduced_unit<cubic_yard, dim_volume, yard> {};
|
||||
struct cubic_yard : derived_unit<cubic_yard, dim_volume, yard> {};
|
||||
|
||||
template<UnitOf<dim_volume> U, Representation Rep = double>
|
||||
using volume = quantity<dim_volume, U, Rep>;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct square_foot : deduced_unit<square_foot, si::dim_area, si::international::foot> {};
|
||||
struct square_foot : derived_unit<square_foot, si::dim_area, si::international::foot> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct mile_per_hour : deduced_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
|
||||
struct mile_per_hour : derived_unit<mile_per_hour, si::dim_speed, si::international::mile, si::hour> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
@@ -35,7 +35,7 @@
|
||||
|
||||
namespace units::isq::si::international {
|
||||
|
||||
struct cubic_foot : deduced_unit<cubic_foot, si::dim_volume, si::international::foot> {};
|
||||
struct cubic_foot : derived_unit<cubic_foot, si::dim_volume, si::international::foot> {};
|
||||
|
||||
#ifndef UNITS_NO_LITERALS
|
||||
|
||||
|
@@ -37,26 +37,26 @@ namespace units::isq::si {
|
||||
struct square_metre : unit<square_metre> {};
|
||||
struct dim_area : isq::dim_area<dim_area, square_metre, dim_length> {};
|
||||
|
||||
struct square_yoctometre : deduced_unit<square_yoctometre, dim_area, yoctometre> {};
|
||||
struct square_zeptometre : deduced_unit<square_zeptometre, dim_area, zeptometre> {};
|
||||
struct square_attometre : deduced_unit<square_attometre, dim_area, attometre> {};
|
||||
struct square_femtometre : deduced_unit<square_femtometre, dim_area, femtometre> {};
|
||||
struct square_picometre : deduced_unit<square_picometre, dim_area, picometre> {};
|
||||
struct square_nanometre : deduced_unit<square_nanometre, dim_area, nanometre> {};
|
||||
struct square_micrometre : deduced_unit<square_micrometre, dim_area, micrometre> {};
|
||||
struct square_millimetre : deduced_unit<square_millimetre, dim_area, millimetre> {};
|
||||
struct square_centimetre : deduced_unit<square_centimetre, dim_area, centimetre> {};
|
||||
struct square_decimetre : deduced_unit<square_decimetre, dim_area, decimetre> {};
|
||||
struct square_decametre : deduced_unit<square_decametre, dim_area, decametre> {};
|
||||
struct square_hectometre : deduced_unit<square_hectometre, dim_area, hectometre> {};
|
||||
struct square_kilometre : deduced_unit<square_kilometre, dim_area, kilometre> {};
|
||||
struct square_megametre : deduced_unit<square_megametre, dim_area, megametre> {};
|
||||
struct square_gigametre : deduced_unit<square_gigametre, dim_area, gigametre> {};
|
||||
struct square_terametre : deduced_unit<square_terametre, dim_area, terametre> {};
|
||||
struct square_petametre : deduced_unit<square_petametre, dim_area, petametre> {};
|
||||
struct square_exametre : deduced_unit<square_exametre, dim_area, exametre> {};
|
||||
struct square_zettametre : deduced_unit<square_zettametre, dim_area, zettametre> {};
|
||||
struct square_yottametre : deduced_unit<square_yottametre, dim_area, yottametre> {};
|
||||
struct square_yoctometre : derived_unit<square_yoctometre, dim_area, yoctometre> {};
|
||||
struct square_zeptometre : derived_unit<square_zeptometre, dim_area, zeptometre> {};
|
||||
struct square_attometre : derived_unit<square_attometre, dim_area, attometre> {};
|
||||
struct square_femtometre : derived_unit<square_femtometre, dim_area, femtometre> {};
|
||||
struct square_picometre : derived_unit<square_picometre, dim_area, picometre> {};
|
||||
struct square_nanometre : derived_unit<square_nanometre, dim_area, nanometre> {};
|
||||
struct square_micrometre : derived_unit<square_micrometre, dim_area, micrometre> {};
|
||||
struct square_millimetre : derived_unit<square_millimetre, dim_area, millimetre> {};
|
||||
struct square_centimetre : derived_unit<square_centimetre, dim_area, centimetre> {};
|
||||
struct square_decimetre : derived_unit<square_decimetre, dim_area, decimetre> {};
|
||||
struct square_decametre : derived_unit<square_decametre, dim_area, decametre> {};
|
||||
struct square_hectometre : derived_unit<square_hectometre, dim_area, hectometre> {};
|
||||
struct square_kilometre : derived_unit<square_kilometre, dim_area, kilometre> {};
|
||||
struct square_megametre : derived_unit<square_megametre, dim_area, megametre> {};
|
||||
struct square_gigametre : derived_unit<square_gigametre, dim_area, gigametre> {};
|
||||
struct square_terametre : derived_unit<square_terametre, dim_area, terametre> {};
|
||||
struct square_petametre : derived_unit<square_petametre, dim_area, petametre> {};
|
||||
struct square_exametre : derived_unit<square_exametre, dim_area, exametre> {};
|
||||
struct square_zettametre : derived_unit<square_zettametre, dim_area, zettametre> {};
|
||||
struct square_yottametre : derived_unit<square_yottametre, dim_area, yottametre> {};
|
||||
|
||||
struct hectare : alias_unit<square_hectometre, "ha", no_prefix> {};
|
||||
|
||||
|
@@ -37,7 +37,7 @@ namespace units::isq::si {
|
||||
struct metre_per_second : unit<metre_per_second> {};
|
||||
struct dim_speed : isq::dim_speed<dim_speed, metre_per_second, dim_length, dim_time> {};
|
||||
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
|
||||
template<UnitOf<dim_speed> U, Representation Rep = double>
|
||||
using speed = quantity<dim_speed, U, Rep>;
|
||||
|
@@ -37,26 +37,26 @@ namespace units::isq::si {
|
||||
struct cubic_metre : unit<cubic_metre> {};
|
||||
struct dim_volume : isq::dim_volume<dim_volume, cubic_metre, dim_length> {};
|
||||
|
||||
struct cubic_yoctometre : deduced_unit<cubic_yoctometre, dim_volume, yoctometre> {};
|
||||
struct cubic_zeptometre : deduced_unit<cubic_zeptometre, dim_volume, zeptometre> {};
|
||||
struct cubic_attometre : deduced_unit<cubic_attometre, dim_volume, attometre> {};
|
||||
struct cubic_femtometre : deduced_unit<cubic_femtometre, dim_volume, femtometre> {};
|
||||
struct cubic_picometre : deduced_unit<cubic_picometre, dim_volume, picometre> {};
|
||||
struct cubic_nanometre : deduced_unit<cubic_nanometre, dim_volume, nanometre> {};
|
||||
struct cubic_micrometre : deduced_unit<cubic_micrometre, dim_volume, micrometre> {};
|
||||
struct cubic_millimetre : deduced_unit<cubic_millimetre, dim_volume, millimetre> {};
|
||||
struct cubic_centimetre : deduced_unit<cubic_centimetre, dim_volume, centimetre> {};
|
||||
struct cubic_decimetre : deduced_unit<cubic_decimetre, dim_volume, decimetre> {};
|
||||
struct cubic_decametre : deduced_unit<cubic_decametre, dim_volume, decametre> {};
|
||||
struct cubic_hectometre : deduced_unit<cubic_hectometre, dim_volume, hectometre> {};
|
||||
struct cubic_kilometre : deduced_unit<cubic_kilometre, dim_volume, kilometre> {};
|
||||
struct cubic_megametre : deduced_unit<cubic_megametre, dim_volume, megametre> {};
|
||||
struct cubic_gigametre : deduced_unit<cubic_gigametre, dim_volume, gigametre> {};
|
||||
struct cubic_terametre : deduced_unit<cubic_terametre, dim_volume, terametre> {};
|
||||
struct cubic_petametre : deduced_unit<cubic_petametre, dim_volume, petametre> {};
|
||||
struct cubic_exametre : deduced_unit<cubic_exametre, dim_volume, exametre> {};
|
||||
struct cubic_zettametre : deduced_unit<cubic_zettametre, dim_volume, zettametre> {};
|
||||
struct cubic_yottametre : deduced_unit<cubic_yottametre, dim_volume, yottametre> {};
|
||||
struct cubic_yoctometre : derived_unit<cubic_yoctometre, dim_volume, yoctometre> {};
|
||||
struct cubic_zeptometre : derived_unit<cubic_zeptometre, dim_volume, zeptometre> {};
|
||||
struct cubic_attometre : derived_unit<cubic_attometre, dim_volume, attometre> {};
|
||||
struct cubic_femtometre : derived_unit<cubic_femtometre, dim_volume, femtometre> {};
|
||||
struct cubic_picometre : derived_unit<cubic_picometre, dim_volume, picometre> {};
|
||||
struct cubic_nanometre : derived_unit<cubic_nanometre, dim_volume, nanometre> {};
|
||||
struct cubic_micrometre : derived_unit<cubic_micrometre, dim_volume, micrometre> {};
|
||||
struct cubic_millimetre : derived_unit<cubic_millimetre, dim_volume, millimetre> {};
|
||||
struct cubic_centimetre : derived_unit<cubic_centimetre, dim_volume, centimetre> {};
|
||||
struct cubic_decimetre : derived_unit<cubic_decimetre, dim_volume, decimetre> {};
|
||||
struct cubic_decametre : derived_unit<cubic_decametre, dim_volume, decametre> {};
|
||||
struct cubic_hectometre : derived_unit<cubic_hectometre, dim_volume, hectometre> {};
|
||||
struct cubic_kilometre : derived_unit<cubic_kilometre, dim_volume, kilometre> {};
|
||||
struct cubic_megametre : derived_unit<cubic_megametre, dim_volume, megametre> {};
|
||||
struct cubic_gigametre : derived_unit<cubic_gigametre, dim_volume, gigametre> {};
|
||||
struct cubic_terametre : derived_unit<cubic_terametre, dim_volume, terametre> {};
|
||||
struct cubic_petametre : derived_unit<cubic_petametre, dim_volume, petametre> {};
|
||||
struct cubic_exametre : derived_unit<cubic_exametre, dim_volume, exametre> {};
|
||||
struct cubic_zettametre : derived_unit<cubic_zettametre, dim_volume, zettametre> {};
|
||||
struct cubic_yottametre : derived_unit<cubic_yottametre, dim_volume, yottametre> {};
|
||||
|
||||
struct litre : alias_unit<cubic_decimetre, "l", prefix> {};
|
||||
struct yoctolitre : prefixed_alias_unit<cubic_nanometre, yocto, litre> {};
|
||||
|
@@ -194,7 +194,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("quantity with a deduced unit")
|
||||
SECTION("quantity with a derived unit")
|
||||
{
|
||||
SECTION("coherent derived unit")
|
||||
{
|
||||
@@ -287,7 +287,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
|
||||
|
||||
SECTION("surface tension")
|
||||
{
|
||||
struct newton_per_centimetre : deduced_unit<newton_per_centimetre, si::dim_surface_tension, newton, centimetre> {};
|
||||
struct newton_per_centimetre : derived_unit<newton_per_centimetre, si::dim_surface_tension, newton, centimetre> {};
|
||||
const surface_tension<newton_per_centimetre> q(123);
|
||||
os << q;
|
||||
|
||||
|
@@ -65,7 +65,7 @@ namespace {
|
||||
|
||||
struct kilogram_per_second : unit<kilogram_per_second> {};
|
||||
struct dim_mass_rate : derived_dimension<dim_mass_rate, kilogram_per_second, units::exponent<dim_mass, 1>, units::exponent<dim_time, -1>> {};
|
||||
struct kilogram_per_hour : deduced_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
||||
struct kilogram_per_hour : derived_unit<kilogram_per_hour, dim_mass_rate, kilogram, hour> {};
|
||||
[[maybe_unused]] constexpr auto a = 1_q_kg / 1_q_h;
|
||||
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ static_assert([]<Prefix P>(P) { return !requires { typename prefixed_unit<struct
|
||||
|
||||
struct metre_per_second : unit<metre_per_second> {};
|
||||
struct dim_speed : derived_dimension<dim_speed, metre_per_second, units::exponent<dim_length, 1>, units::exponent<dim_time, -1>> {};
|
||||
struct kilometre_per_hour : deduced_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
struct kilometre_per_hour : derived_unit<kilometre_per_hour, dim_speed, kilometre, hour> {};
|
||||
|
||||
static_assert(equivalent<metre::named_unit, metre>);
|
||||
static_assert(equivalent<metre::scaled_unit, metre>);
|
||||
|
Reference in New Issue
Block a user