refactor: Repetitive inline constexpr removed as no longer needed

Not needed anymore as stated in cplusplus/draft#4601
This commit is contained in:
Mateusz Pusz
2024-09-05 08:43:36 +02:00
parent 2a4e1e3d95
commit 2e840cfdb4
95 changed files with 1765 additions and 1772 deletions

View File

@@ -49,19 +49,19 @@ As a side effect, we introduced a :boom: **breaking change** :boom:. We can't us
hertz anymore: hertz anymore:
```cpp ```cpp
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz; constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
``` ```
and have to type either: and have to type either:
```cpp ```cpp
inline constexpr struct hertz : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz; constexpr struct hertz : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
``` ```
or or
```cpp ```cpp
inline constexpr struct hertz : named_unit<"Hz", inverse(second), kind_of<isq::frequency>> {} hertz; constexpr struct hertz : named_unit<"Hz", inverse(second), kind_of<isq::frequency>> {} hertz;
``` ```
To be consistent, we applied the same change to the dimensions and quantity To be consistent, we applied the same change to the dimensions and quantity
@@ -70,13 +70,13 @@ specifications definitions. Now, to define a _frequency_ we have to type:
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct frequency : quantity_spec<inverse(period_duration)> {} frequency; constexpr struct frequency : quantity_spec<inverse(period_duration)> {} frequency;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct frequency : quantity_spec<frequency, inverse(period_duration)> {} frequency; constexpr struct frequency : quantity_spec<frequency, inverse(period_duration)> {} frequency;
``` ```
=== "Portable" === "Portable"
@@ -145,11 +145,11 @@ If we derive from the same instantiation of `absolute_point_origin` we end up wi
point origin. This change allows us to provide different names for the same temperature points: point origin. This change allows us to provide different names for the same temperature points:
```cpp ```cpp
inline constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
inline constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin; constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin;
inline constexpr struct ice_point : relative_point_origin<absolute_zero + 273.15 * kelvin> {} ice_point; constexpr struct ice_point : relative_point_origin<absolute_zero + 273.15 * kelvin> {} ice_point;
inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius; constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius;
``` ```
Please note that this is a :boom: **breaking change** :boom: as well. Please note that this is a :boom: **breaking change** :boom: as well.

View File

@@ -281,13 +281,13 @@ is why it was renamed to `symbol_text` (:boom: **breaking change** :boom:).
=== "Now" === "Now"
```cpp ```cpp
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
``` ```
=== "Before" === "Before"
```cpp ```cpp
inline constexpr struct ohm : named_unit<basic_symbol_text{"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm : named_unit<basic_symbol_text{"Ω", "ohm"}, volt / ampere> {} ohm;
``` ```
!!! note !!! note
@@ -295,7 +295,7 @@ is why it was renamed to `symbol_text` (:boom: **breaking change** :boom:).
On C++20-compliant compilers it should be enough to type the following in the unit's definition: On C++20-compliant compilers it should be enough to type the following in the unit's definition:
```cpp ```cpp
inline constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
``` ```
@@ -307,31 +307,31 @@ marked `final` (:boom: **breaking change** :boom:).
=== "Now" === "Now"
```cpp ```cpp
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
inline constexpr struct length final : quantity_spec<dim_length> {} length; constexpr struct length final : quantity_spec<dim_length> {} length;
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
inline constexpr auto zeroth_kelvin = absolute_zero; constexpr auto zeroth_kelvin = absolute_zero;
inline constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin; constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
inline constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point; constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
inline constexpr auto zeroth_degree_Celsius = ice_point; constexpr auto zeroth_degree_Celsius = ice_point;
inline constexpr struct degree_Celsius final : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; constexpr struct degree_Celsius final : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
``` ```
=== "Before" === "Before"
```cpp ```cpp
inline constexpr struct dim_length : base_dimension<"L"> {} dim_length; constexpr struct dim_length : base_dimension<"L"> {} dim_length;
inline constexpr struct length : quantity_spec<dim_length> {} length; constexpr struct length : quantity_spec<dim_length> {} length;
inline constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
inline constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin; constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin;
inline constexpr struct kelvin : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin; constexpr struct kelvin : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
inline constexpr struct ice_point : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point; constexpr struct ice_point : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius; constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius;
inline constexpr struct degree_Celsius : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; constexpr struct degree_Celsius : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
``` ```
Please also note, that the `absolute_point_origin` does not use CRTP idiom anymore (:boom: **breaking change** :boom:). Please also note, that the `absolute_point_origin` does not use CRTP idiom anymore (:boom: **breaking change** :boom:).
@@ -509,13 +509,13 @@ conversion factor. Here is a comparison of the code with previous and current de
=== "Now" === "Now"
```cpp ```cpp
inline constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard; constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
inline constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot; constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot;
``` ```
=== "Before" === "Before"
```cpp ```cpp
inline constexpr struct yard : named_unit<"yd", mag<ratio{9'144, 10'000}> * si::metre> {} yard; constexpr struct yard : named_unit<"yd", mag<ratio{9'144, 10'000}> * si::metre> {} yard;
inline constexpr struct foot : named_unit<"ft", mag<ratio{1, 3}> * yard> {} foot; constexpr struct foot : named_unit<"ft", mag<ratio{1, 3}> * yard> {} foot;
``` ```

View File

@@ -33,7 +33,7 @@ The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units)
using namespace mp_units; using namespace mp_units;
inline constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot; constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
int main() int main()
{ {
@@ -53,7 +53,7 @@ The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units)
using namespace mp_units; using namespace mp_units;
inline constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot; constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
int main() int main()
{ {

View File

@@ -97,15 +97,15 @@ enumeration can be appended to the `quantity_spec` describing such a quantity ty
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector; constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
inline constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement; constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector; constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector;
inline constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement; constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement;
``` ```
=== "Portable" === "Portable"
@@ -126,13 +126,13 @@ character override is needed):
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity; constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct velocity final : quantity_spec<velocity, speed, position_vector / duration> {} velocity; constexpr struct velocity final : quantity_spec<velocity, speed, position_vector / duration> {} velocity;
``` ```
=== "Portable" === "Portable"
@@ -179,7 +179,7 @@ For example, here is how it can be done for the [P1385](https://wg21.link/p1385)
using la_vector = STD_LA::fixed_size_column_vector<double, 3>; using la_vector = STD_LA::fixed_size_column_vector<double, 3>;
template<> template<>
inline constexpr bool mp_units::is_vector<la_vector> = true; constexpr bool mp_units::is_vector<la_vector> = true;
``` ```
With the above, we can use `la_vector` as a representation type for our quantity: With the above, we can use `la_vector` as a representation type for our quantity:
@@ -233,7 +233,7 @@ For example, we can do the following:
```cpp ```cpp
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
``` ```
which says that every type that can be used as a scalar representation is also allowed for vector which says that every type that can be used as a scalar representation is also allowed for vector

View File

@@ -180,7 +180,7 @@ with `true` for one or more of the following variable templates:
```cpp ```cpp
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
``` ```
@@ -219,7 +219,7 @@ implicitly convertible from quantity specification `V`, which means that `V` mus
However, if we define `mean_sea_level` in the following way: However, if we define `mean_sea_level` in the following way:
```cpp ```cpp
inline constexpr struct mean_sea_level final : absolute_point_origin<isq::altitude> {} mean_sea_level; constexpr struct mean_sea_level final : absolute_point_origin<isq::altitude> {} mean_sea_level;
``` ```
then it can't be used as a point origin for _points_ of `isq::length` or `isq::width` as none of them then it can't be used as a point origin for _points_ of `isq::length` or `isq::width` as none of them

View File

@@ -60,8 +60,8 @@ For example:
the following way: the following way:
```cpp ```cpp
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time; constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
``` ```
[Derived dimensions](../../appendix/glossary.md#derived-dimension) are implicitly created [Derived dimensions](../../appendix/glossary.md#derived-dimension) are implicitly created
@@ -71,9 +71,9 @@ provided in the [quantity specification](../../appendix/glossary.md#quantity_spe
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<dim_length> {} length; constexpr struct length final : quantity_spec<dim_length> {} length;
inline constexpr struct time final : quantity_spec<dim_time> {} time; constexpr struct time final : quantity_spec<dim_time> {} time;
inline constexpr struct speed final : quantity_spec<length / time> {} speed; constexpr struct speed final : quantity_spec<length / time> {} speed;
static_assert(speed.dimension == dim_length / dim_time); static_assert(speed.dimension == dim_length / dim_time);
``` ```
@@ -81,9 +81,9 @@ provided in the [quantity specification](../../appendix/glossary.md#quantity_spe
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<length, dim_length> {} length; constexpr struct length final : quantity_spec<length, dim_length> {} length;
inline constexpr struct time final : quantity_spec<time, dim_time> {} time; constexpr struct time final : quantity_spec<time, dim_time> {} time;
inline constexpr struct speed final : quantity_spec<speed, length / time> {} speed; constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
static_assert(speed.dimension == dim_length / dim_time); static_assert(speed.dimension == dim_length / dim_time);
``` ```
@@ -183,17 +183,17 @@ Quantity specification can be defined by the user in one of the following ways:
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<dim_length> {} length; constexpr struct length final : quantity_spec<dim_length> {} length;
inline constexpr struct height final : quantity_spec<length> {} height; constexpr struct height final : quantity_spec<length> {} height;
inline constexpr struct speed final : quantity_spec<length / time> {} speed; constexpr struct speed final : quantity_spec<length / time> {} speed;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<length, dim_length> {} length; constexpr struct length final : quantity_spec<length, dim_length> {} length;
inline constexpr struct height final : quantity_spec<height, length> {} height; constexpr struct height final : quantity_spec<height, length> {} height;
inline constexpr struct speed final : quantity_spec<speed, length / time> {} speed; constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
``` ```
=== "Portable" === "Portable"
@@ -232,15 +232,15 @@ A unit can be defined by the user in one of the following ways:
```cpp ```cpp
template<PrefixableUnit U> struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U{}> {}; template<PrefixableUnit U> struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U{}> {};
template<PrefixableUnit auto U> inline constexpr kilo_<decltype(U)> kilo; template<PrefixableUnit auto U> constexpr kilo_<decltype(U)> kilo;
inline constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second; constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute; constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram; constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
inline constexpr auto kilogram = kilo<gram>; constexpr auto kilogram = kilo<gram>;
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct speed_of_light_in_vacuum final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; constexpr struct speed_of_light_in_vacuum final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
``` ```
The [unit equation](../../appendix/glossary.md#unit-equation) of `si::metre / si::second` results The [unit equation](../../appendix/glossary.md#unit-equation) of `si::metre / si::second` results
@@ -346,13 +346,13 @@ For example:
- the absolute point origin can be defined in the following way: - the absolute point origin can be defined in the following way:
```cpp ```cpp
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
``` ```
- the relative point origin can be defined in the following way: - the relative point origin can be defined in the following way:
```cpp ```cpp
inline constexpr struct ice_point final : relative_point_origin<absolute_zero + 273'150 * milli<kelvin>> {} ice_point; constexpr struct ice_point final : relative_point_origin<absolute_zero + 273'150 * milli<kelvin>> {} ice_point;
``` ```

View File

@@ -113,7 +113,7 @@ that uses a unit that is proportional to the ratio of kilometers per megaparsecs
units of _length_: units of _length_:
```cpp ```cpp
inline constexpr struct hubble_constant final : constexpr struct hubble_constant final :
named_unit<{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant; named_unit<{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
``` ```
@@ -158,10 +158,10 @@ Besides the unit `one`, there are a few other scaled units predefined in the lib
with dimensionless quantities: with dimensionless quantities:
```cpp ```cpp
inline constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent; constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
inline constexpr struct per_mille final : named_unit<{u8"‰", "%o"}, mag_ratio<1, 1000> * one> {} per_mille; constexpr struct per_mille final : named_unit<{u8"‰", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
inline constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million; constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million; constexpr auto ppm = parts_per_million;
``` ```
### Superpowers of the unit `one` ### Superpowers of the unit `one`
@@ -271,17 +271,17 @@ to the quantity specification:
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure; constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure;
inline constexpr struct solid_angular_measure final : quantity_spec<dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure; constexpr struct solid_angular_measure final : quantity_spec<dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure;
inline constexpr struct storage_capacity final : quantity_spec<dimensionless, is_kind> {} storage_capacity; constexpr struct storage_capacity final : quantity_spec<dimensionless, is_kind> {} storage_capacity;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct angular_measure final : quantity_spec<angular_measure, dimensionless, arc_length / radius, is_kind> {} angular_measure; constexpr struct angular_measure final : quantity_spec<angular_measure, dimensionless, arc_length / radius, is_kind> {} angular_measure;
inline constexpr struct solid_angular_measure final : quantity_spec<solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure; constexpr struct solid_angular_measure final : quantity_spec<solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure;
inline constexpr struct storage_capacity final : quantity_spec<storage_capacity, dimensionless, is_kind> {} storage_capacity; constexpr struct storage_capacity final : quantity_spec<storage_capacity, dimensionless, is_kind> {} storage_capacity;
``` ```
=== "Portable" === "Portable"
@@ -296,9 +296,9 @@ With the above, we can constrain `radian`, `steradian`, and `bit` to be allowed
specific quantity kinds only: specific quantity kinds only:
```cpp ```cpp
inline constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian; constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
inline constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian; constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
inline constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit; constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
``` ```
but still allow the usage of `one` and its scaled versions for such quantities. but still allow the usage of `one` and its scaled versions for such quantities.

View File

@@ -39,12 +39,12 @@ namespace si {
namespace si2019 { namespace si2019 {
inline constexpr struct speed_of_light_in_vacuum final : constexpr struct speed_of_light_in_vacuum final :
named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
} // namespace si2019 } // namespace si2019
inline constexpr struct magnetic_constant final : constexpr struct magnetic_constant final :
named_unit<{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant; named_unit<{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant;
} // namespace mp_units::si } // namespace mp_units::si

View File

@@ -6,8 +6,8 @@ The **mp-units** library decided to use a rather unusual pattern to define entit
Here is how we define `metre` and `second` [SI](../../appendix/glossary.md#si) base units: Here is how we define `metre` and `second` [SI](../../appendix/glossary.md#si) base units:
```cpp ```cpp
inline constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre; constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
inline constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second; constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
``` ```
Please note that the above reuses the same identifier for a type and its value. The rationale Please note that the above reuses the same identifier for a type and its value. The rationale
@@ -97,9 +97,9 @@ the value-based [unit equation](../../appendix/glossary.md#unit-equation) to a c
definition: definition:
```cpp ```cpp
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal; constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule; constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
``` ```

View File

@@ -316,12 +316,12 @@ Let's see another example:
using namespace mp_units; using namespace mp_units;
// add a custom quantity type of kind isq::length // add a custom quantity type of kind isq::length
inline constexpr struct horizontal_length final : constexpr struct horizontal_length final :
quantity_spec<isq::length> {} horizontal_length; quantity_spec<isq::length> {} horizontal_length;
// add a custom derived quantity type of kind isq::area // add a custom derived quantity type of kind isq::area
// with a constrained quantity equation // with a constrained quantity equation
inline constexpr struct horizontal_area final : constexpr struct horizontal_area final :
quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area; quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area;
class StorageTank { class StorageTank {
@@ -429,12 +429,12 @@ Let's see another example:
using namespace mp_units; using namespace mp_units;
// add a custom quantity type of kind isq::length // add a custom quantity type of kind isq::length
inline constexpr struct horizontal_length final : constexpr struct horizontal_length final :
quantity_spec<isq::length> {} horizontal_length; quantity_spec<isq::length> {} horizontal_length;
// add a custom derived quantity type of kind isq::area // add a custom derived quantity type of kind isq::area
// with a constrained quantity equation // with a constrained quantity equation
inline constexpr struct horizontal_area final : constexpr struct horizontal_area final :
quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area; quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area;
class StorageTank { class StorageTank {

View File

@@ -148,45 +148,45 @@ For example, here is how the above quantity kind tree can be modeled in the libr
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<dim_length> {} length; constexpr struct length final : quantity_spec<dim_length> {} length;
inline constexpr struct width final : quantity_spec<length> {} width; constexpr struct width final : quantity_spec<length> {} width;
inline constexpr auto breadth = width; constexpr auto breadth = width;
inline constexpr struct height final : quantity_spec<length> {} height; constexpr struct height final : quantity_spec<length> {} height;
inline constexpr auto depth = height; constexpr auto depth = height;
inline constexpr auto altitude = height; constexpr auto altitude = height;
inline constexpr struct thickness final : quantity_spec<width> {} thickness; constexpr struct thickness final : quantity_spec<width> {} thickness;
inline constexpr struct diameter final : quantity_spec<width> {} diameter; constexpr struct diameter final : quantity_spec<width> {} diameter;
inline constexpr struct radius final : quantity_spec<width> {} radius; constexpr struct radius final : quantity_spec<width> {} radius;
inline constexpr struct radius_of_curvature final : quantity_spec<radius> {} radius_of_curvature; constexpr struct radius_of_curvature final : quantity_spec<radius> {} radius_of_curvature;
inline constexpr struct path_length final : quantity_spec<length> {} path_length; constexpr struct path_length final : quantity_spec<length> {} path_length;
inline constexpr auto arc_length = path_length; constexpr auto arc_length = path_length;
inline constexpr struct distance final : quantity_spec<path_length> {} distance; constexpr struct distance final : quantity_spec<path_length> {} distance;
inline constexpr struct radial_distance final : quantity_spec<distance> {} radial_distance; constexpr struct radial_distance final : quantity_spec<distance> {} radial_distance;
inline constexpr struct wavelength final : quantity_spec<length> {} wavelength; constexpr struct wavelength final : quantity_spec<length> {} wavelength;
inline constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector; constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
inline constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement; constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement;
``` ```
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct length final : quantity_spec<length, dim_length> {} length; constexpr struct length final : quantity_spec<length, dim_length> {} length;
inline constexpr struct width final : quantity_spec<width, length> {} width; constexpr struct width final : quantity_spec<width, length> {} width;
inline constexpr auto breadth = width; constexpr auto breadth = width;
inline constexpr struct height final : quantity_spec<height, length> {} height; constexpr struct height final : quantity_spec<height, length> {} height;
inline constexpr auto depth = height; constexpr auto depth = height;
inline constexpr auto altitude = height; constexpr auto altitude = height;
inline constexpr struct thickness final : quantity_spec<thickness, width> {} thickness; constexpr struct thickness final : quantity_spec<thickness, width> {} thickness;
inline constexpr struct diameter final : quantity_spec<diameter, width> {} diameter; constexpr struct diameter final : quantity_spec<diameter, width> {} diameter;
inline constexpr struct radius final : quantity_spec<radius, width> {} radius; constexpr struct radius final : quantity_spec<radius, width> {} radius;
inline constexpr struct radius_of_curvature final : quantity_spec<radius_of_curvature, radius> {} radius_of_curvature; constexpr struct radius_of_curvature final : quantity_spec<radius_of_curvature, radius> {} radius_of_curvature;
inline constexpr struct path_length final : quantity_spec<path_length, length> {} path_length; constexpr struct path_length final : quantity_spec<path_length, length> {} path_length;
inline constexpr auto arc_length = path_length; constexpr auto arc_length = path_length;
inline constexpr struct distance final : quantity_spec<distance, path_length> {} distance; constexpr struct distance final : quantity_spec<distance, path_length> {} distance;
inline constexpr struct radial_distance final : quantity_spec<radial_distance, distance> {} radial_distance; constexpr struct radial_distance final : quantity_spec<radial_distance, distance> {} radial_distance;
inline constexpr struct wavelength final : quantity_spec<wavelength, length> {} wavelength; constexpr struct wavelength final : quantity_spec<wavelength, length> {} wavelength;
inline constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector; constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector;
inline constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement; constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement;
``` ```
=== "Portable" === "Portable"
@@ -194,16 +194,16 @@ For example, here is how the above quantity kind tree can be modeled in the libr
```cpp ```cpp
QUANTITY_SPEC(length, dim_length); QUANTITY_SPEC(length, dim_length);
QUANTITY_SPEC(width, length); QUANTITY_SPEC(width, length);
inline constexpr auto breadth = width; constexpr auto breadth = width;
QUANTITY_SPEC(height, length); QUANTITY_SPEC(height, length);
inline constexpr auto depth = height; constexpr auto depth = height;
inline constexpr auto altitude = height; constexpr auto altitude = height;
QUANTITY_SPEC(thickness, width); QUANTITY_SPEC(thickness, width);
QUANTITY_SPEC(diameter, width); QUANTITY_SPEC(diameter, width);
QUANTITY_SPEC(radius, width); QUANTITY_SPEC(radius, width);
QUANTITY_SPEC(radius_of_curvature, radius); QUANTITY_SPEC(radius_of_curvature, radius);
QUANTITY_SPEC(path_length, length); QUANTITY_SPEC(path_length, length);
inline constexpr auto arc_length = path_length; constexpr auto arc_length = path_length;
QUANTITY_SPEC(distance, path_length); QUANTITY_SPEC(distance, path_length);
QUANTITY_SPEC(radial_distance, distance); QUANTITY_SPEC(radial_distance, distance);
QUANTITY_SPEC(wavelength, length); QUANTITY_SPEC(wavelength, length);

View File

@@ -26,7 +26,7 @@ this is expressed by associating a quantity kind (that we discussed in detail in
previous chapter) with a unit that is used to express it: previous chapter) with a unit that is used to express it:
```cpp ```cpp
inline constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre; constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
``` ```
!!! important !!! important
@@ -67,7 +67,7 @@ of a specific predefined [unit equation](../../appendix/glossary.md#unit-equatio
For example, a unit of _power_ quantity is defined in the library as: For example, a unit of _power_ quantity is defined in the library as:
```cpp ```cpp
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt; constexpr struct watt final : named_unit<"W", joule / second> {} watt;
``` ```
However, a _power_ quantity can be expressed in other units as well. For example, However, a _power_ quantity can be expressed in other units as well. For example,
@@ -110,8 +110,8 @@ The library allows constraining such units to work only with quantities of a spe
the following way: the following way:
```cpp ```cpp
inline constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz; constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
inline constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel; constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel;
``` ```
With the above, `hertz` can only be used with _frequencies_, while `becquerel` should only be used with With the above, `hertz` can only be used with _frequencies_, while `becquerel` should only be used with
@@ -138,14 +138,14 @@ Each prefix is implemented similarly to the following:
```cpp ```cpp
template<PrefixableUnit U> struct quecto_ : prefixed_unit<"q", mag_power<10, -30>, U{}> {}; template<PrefixableUnit U> struct quecto_ : prefixed_unit<"q", mag_power<10, -30>, U{}> {};
template<PrefixableUnit auto U> inline constexpr quecto_<decltype(U)> quecto; template<PrefixableUnit auto U> constexpr quecto_<decltype(U)> quecto;
``` ```
and then a [PrefixableUnit](concepts.md#PrefixableUnit) can be prefixed in the following and then a [PrefixableUnit](concepts.md#PrefixableUnit) can be prefixed in the following
way: way:
```cpp ```cpp
inline constexpr auto qm = quecto<metre>; constexpr auto qm = quecto<metre>;
``` ```
The usage of `mag_power` not only enables providing support for SI prefixes, but it can also The usage of `mag_power` not only enables providing support for SI prefixes, but it can also
@@ -154,7 +154,7 @@ IT industry can be implemented as:
```cpp ```cpp
template<PrefixableUnit U> struct yobi_ : prefixed_unit<"Yi", mag_power<2, 80>, U{}> {}; template<PrefixableUnit U> struct yobi_ : prefixed_unit<"Yi", mag_power<2, 80>, U{}> {};
template<PrefixableUnit auto U> inline constexpr yobi_<decltype(U)> yobi; template<PrefixableUnit auto U> constexpr yobi_<decltype(U)> yobi;
``` ```
## Scaled units ## Scaled units
@@ -168,25 +168,25 @@ be explicitly expressed with predefined SI prefixes. Those include units like mi
electronvolt: electronvolt:
```cpp ```cpp
inline constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute; constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
inline constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour; constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour;
inline constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt; constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt;
``` ```
Also, units of other [systems of units](../../appendix/glossary.md#system-of-units) are often defined Also, units of other [systems of units](../../appendix/glossary.md#system-of-units) are often defined
in terms of scaled versions of the SI units. For example, the international yard is defined as: in terms of scaled versions of the SI units. For example, the international yard is defined as:
```cpp ```cpp
inline constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard; constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
``` ```
For some units, a magnitude might also be irrational. The best example here is a `degree` which For some units, a magnitude might also be irrational. The best example here is a `degree` which
is defined using a floating-point magnitude having a factor of the number π (Pi): is defined using a floating-point magnitude having a factor of the number π (Pi):
```cpp ```cpp
inline constexpr struct mag_pi final : magnitude<std::numbers::pi_v<long double>> {} mag_pi; constexpr struct mag_pi final : magnitude<std::numbers::pi_v<long double>> {} mag_pi;
``` ```
```cpp ```cpp
inline constexpr struct degree final : named_unit<{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree; constexpr struct degree final : named_unit<{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
``` ```

View File

@@ -33,30 +33,30 @@ and units of derived quantities.
=== "Dimensions" === "Dimensions"
```cpp ```cpp
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass; constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time; constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
inline constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current; constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current;
inline constexpr struct dim_thermodynamic_temperature final : base_dimension<{u8"Θ", "O"}> {} dim_thermodynamic_temperature; constexpr struct dim_thermodynamic_temperature final : base_dimension<{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
inline constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance; constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance;
inline constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity; constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity;
``` ```
=== "Units" === "Units"
```cpp ```cpp
inline constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second; constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
inline constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre; constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram; constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
inline constexpr auto kilogram = kilo<gram>; constexpr auto kilogram = kilo<gram>;
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule; constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt; constexpr struct watt final : named_unit<"W", joule / second> {} watt;
inline constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb; constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
inline constexpr struct volt final : named_unit<"V", watt / ampere> {} volt; constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
inline constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad; constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
inline constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
``` ```
=== "Prefixes" === "Prefixes"
@@ -75,13 +75,13 @@ and units of derived quantities.
=== "Constants" === "Constants"
```cpp ```cpp
inline constexpr struct hyperfine_structure_transition_frequency_of_cs final : named_unit<{u8"Δν_Cs", "dv_Cs"}, mag<9'192'631'770> * hertz> {} hyperfine_structure_transition_frequency_of_cs; constexpr struct hyperfine_structure_transition_frequency_of_cs final : named_unit<{u8"Δν_Cs", "dv_Cs"}, mag<9'192'631'770> * hertz> {} hyperfine_structure_transition_frequency_of_cs;
inline constexpr struct speed_of_light_in_vacuum final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; constexpr struct speed_of_light_in_vacuum final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
inline constexpr struct planck_constant final : named_unit<"h", mag_ratio<662'607'015, 100'000'000> * mag_power<10, -34> * joule * second> {} planck_constant; constexpr struct planck_constant final : named_unit<"h", mag_ratio<662'607'015, 100'000'000> * mag_power<10, -34> * joule * second> {} planck_constant;
inline constexpr struct elementary_charge final : named_unit<"e", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * coulomb> {} elementary_charge; constexpr struct elementary_charge final : named_unit<"e", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * coulomb> {} elementary_charge;
inline constexpr struct boltzmann_constant final : named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant; constexpr struct boltzmann_constant final : named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant;
inline constexpr struct avogadro_constant final : named_unit<"N_A", mag_ratio<602'214'076, 100'000'000> * mag_power<10, 23> / mole> {} avogadro_constant; constexpr struct avogadro_constant final : named_unit<"N_A", mag_ratio<602'214'076, 100'000'000> * mag_power<10, 23> / mole> {} avogadro_constant;
inline constexpr struct luminous_efficacy final : named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy; constexpr struct luminous_efficacy final : named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
``` ```
!!! important !!! important
@@ -105,7 +105,7 @@ and units of derived quantities.
template name to initialize it with two symbols: template name to initialize it with two symbols:
```cpp ```cpp
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
``` ```
@@ -288,7 +288,7 @@ specialization for a specific unit:
```cpp ```cpp
template<> template<>
inline constexpr bool space_before_unit_symbol<non_si::degree> = false; constexpr bool space_before_unit_symbol<non_si::degree> = false;
``` ```
!!! note !!! note

View File

@@ -196,7 +196,7 @@ origin.
![affine_space_2](affine_space_2.svg){style="width:80%;display: block;margin: 0 auto;"} ![affine_space_2](affine_space_2.svg){style="width:80%;display: block;margin: 0 auto;"}
```cpp ```cpp
inline constexpr struct origin final : absolute_point_origin<isq::distance> {} origin; constexpr struct origin final : absolute_point_origin<isq::distance> {} origin;
// quantity_point<si::metre, origin> qp1{100 * m}; // Compile-time error // quantity_point<si::metre, origin> qp1{100 * m}; // Compile-time error
// quantity_point<si::metre, origin> qp2{delta<m>(120)}; // Compile-time error // quantity_point<si::metre, origin> qp2{delta<m>(120)}; // Compile-time error
@@ -265,8 +265,8 @@ type and unit is being used:
![affine_space_3](affine_space_3.svg){style="width:80%;display: block;margin: 0 auto;"} ![affine_space_3](affine_space_3.svg){style="width:80%;display: block;margin: 0 auto;"}
```cpp ```cpp
inline constexpr struct origin1 final : absolute_point_origin<isq::distance> {} origin1; constexpr struct origin1 final : absolute_point_origin<isq::distance> {} origin1;
inline constexpr struct origin2 final : absolute_point_origin<isq::distance> {} origin2; constexpr struct origin2 final : absolute_point_origin<isq::distance> {} origin2;
quantity_point qp1 = origin1 + 100 * m; quantity_point qp1 = origin1 + 100 * m;
quantity_point qp2 = origin2 + 120 * m; quantity_point qp2 = origin2 + 120 * m;
@@ -300,10 +300,10 @@ For such cases, relative point origins should be used:
![affine_space_4](affine_space_4.svg){style="width:80%;display: block;margin: 0 auto;"} ![affine_space_4](affine_space_4.svg){style="width:80%;display: block;margin: 0 auto;"}
```cpp ```cpp
inline constexpr struct A final : absolute_point_origin<isq::distance> {} A; constexpr struct A final : absolute_point_origin<isq::distance> {} A;
inline constexpr struct B final : relative_point_origin<A + 10 * m> {} B; constexpr struct B final : relative_point_origin<A + 10 * m> {} B;
inline constexpr struct C final : relative_point_origin<B + 10 * m> {} C; constexpr struct C final : relative_point_origin<B + 10 * m> {} C;
inline constexpr struct D final : relative_point_origin<A + 30 * m> {} D; constexpr struct D final : relative_point_origin<A + 30 * m> {} D;
quantity_point qp1 = C + 100 * m; quantity_point qp1 = C + 100 * m;
quantity_point qp2 = D + 120 * m; quantity_point qp2 = D + 120 * m;
@@ -408,17 +408,17 @@ point origins for this purpose:
```cpp ```cpp
namespace si { namespace si {
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
inline constexpr auto zeroth_kelvin = absolute_zero; constexpr auto zeroth_kelvin = absolute_zero;
inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)}> {} ice_point; constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)}> {} ice_point;
inline constexpr auto zeroth_degree_Celsius = ice_point; constexpr auto zeroth_degree_Celsius = ice_point;
} }
namespace usc { namespace usc {
inline constexpr struct zeroth_degree_Fahrenheit final : constexpr struct zeroth_degree_Fahrenheit final :
relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_degree_Fahrenheit; relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_degree_Fahrenheit;
} }
@@ -442,16 +442,16 @@ definitions:
```cpp ```cpp
namespace si { namespace si {
inline constexpr struct kelvin final : constexpr struct kelvin final :
named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin; named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
inline constexpr struct degree_Celsius final : constexpr struct degree_Celsius final :
named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
} }
namespace usc { namespace usc {
inline constexpr struct degree_Fahrenheit final : constexpr struct degree_Fahrenheit final :
named_unit<{u8"℉", "`F"}, mag_ratio<5, 9> * si::degree_Celsius, named_unit<{u8"℉", "`F"}, mag_ratio<5, 9> * si::degree_Celsius,
zeroth_degree_Fahrenheit> {} degree_Fahrenheit; zeroth_degree_Fahrenheit> {} degree_Fahrenheit;

View File

@@ -85,16 +85,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
=== "C++23" === "C++23"
```cpp ```cpp
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency; constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
inline constexpr struct currency final : quantity_spec<dim_currency> {} currency; constexpr struct currency final : quantity_spec<dim_currency> {} currency;
inline constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar; constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
inline constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar; constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto USD = us_dollar; constexpr auto USD = us_dollar;
inline constexpr auto USD_s = scaled_us_dollar; constexpr auto USD_s = scaled_us_dollar;
} // namespace unit_symbols } // namespace unit_symbols
@@ -105,16 +105,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
=== "C++20" === "C++20"
```cpp ```cpp
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency; constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
inline constexpr struct currency final : quantity_spec<currency, dim_currency> {} currency; constexpr struct currency final : quantity_spec<currency, dim_currency> {} currency;
inline constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar; constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
inline constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar; constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto USD = us_dollar; constexpr auto USD = us_dollar;
inline constexpr auto USD_s = scaled_us_dollar; constexpr auto USD_s = scaled_us_dollar;
} // namespace unit_symbols } // namespace unit_symbols
@@ -125,16 +125,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
=== "Portable" === "Portable"
```cpp ```cpp
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency; constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
QUANTITY_SPEC(currency, dim_currency); QUANTITY_SPEC(currency, dim_currency);
inline constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar; constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
inline constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar; constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto USD = us_dollar; constexpr auto USD = us_dollar;
inline constexpr auto USD_s = scaled_us_dollar; constexpr auto USD_s = scaled_us_dollar;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -249,8 +249,8 @@ include the _mp-units/systems/si/chrono.h_ file to benefit from it. This file pr
to the `std::chrono` abstractions: to the `std::chrono` abstractions:
```cpp ```cpp
inline constexpr struct ts_origin final : relative_point_origin<chrono_point_origin<system_clock> + 1 * h> {} ts_origin; constexpr struct ts_origin final : relative_point_origin<chrono_point_origin<system_clock> + 1 * h> {} ts_origin;
inline constexpr struct my_origin final : absolute_point_origin<isq::time> {} my_origin; constexpr struct my_origin final : absolute_point_origin<isq::time> {} my_origin;
quantity_point qp1 = sys_seconds{1s}; quantity_point qp1 = sys_seconds{1s};
auto tp1 = to_chrono_time_point(qp1); // OK auto tp1 = to_chrono_time_point(qp1); // OK

View File

@@ -29,7 +29,7 @@ your code using **mp-units**:
// ... // ...
inline constexpr struct horizontal_length final : quantity_spec<isq::length> {} horizontal_length; constexpr struct horizontal_length final : quantity_spec<isq::length> {} horizontal_length;
// ... // ...
@@ -45,7 +45,7 @@ your code using **mp-units**:
// ... // ...
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length; constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
// ... // ...
@@ -65,7 +65,7 @@ your code using **mp-units**:
// ... // ...
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length; constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
// ... // ...
@@ -85,7 +85,7 @@ your code using **mp-units**:
// ... // ...
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length; constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
// ... // ...

View File

@@ -40,22 +40,22 @@ import mp_units.core;
using namespace mp_units; using namespace mp_units;
// clang-format off // clang-format off
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency; constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
QUANTITY_SPEC(currency, dim_currency); QUANTITY_SPEC(currency, dim_currency);
inline constexpr struct euro final : named_unit<"EUR", kind_of<currency>> {} euro; constexpr struct euro final : named_unit<"EUR", kind_of<currency>> {} euro;
inline constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar; constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
inline constexpr struct great_british_pound final : named_unit<"GBP", kind_of<currency>> {} great_british_pound; constexpr struct great_british_pound final : named_unit<"GBP", kind_of<currency>> {} great_british_pound;
inline constexpr struct japanese_jen final : named_unit<"JPY", kind_of<currency>> {} japanese_jen; constexpr struct japanese_jen final : named_unit<"JPY", kind_of<currency>> {} japanese_jen;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto EUR = euro; constexpr auto EUR = euro;
inline constexpr auto USD = us_dollar; constexpr auto USD = us_dollar;
inline constexpr auto GBP = great_british_pound; constexpr auto GBP = great_british_pound;
inline constexpr auto JPY = japanese_jen; constexpr auto JPY = japanese_jen;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -44,7 +44,7 @@ import mp_units;
namespace geographic { namespace geographic {
inline constexpr struct mean_sea_level final : mp_units::absolute_point_origin<mp_units::isq::altitude> { constexpr struct mean_sea_level final : mp_units::absolute_point_origin<mp_units::isq::altitude> {
} mean_sea_level; } mean_sea_level;
using msl_altitude = mp_units::quantity_point<mp_units::isq::altitude[mp_units::si::metre], mean_sea_level>; using msl_altitude = mp_units::quantity_point<mp_units::isq::altitude[mp_units::si::metre], mean_sea_level>;
@@ -72,9 +72,9 @@ struct MP_UNITS_STD_FMT::formatter<geographic::msl_altitude, Char> :
namespace geographic { namespace geographic {
inline constexpr struct equator final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> { constexpr struct equator final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
} equator; } equator;
inline constexpr struct prime_meridian final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> { constexpr struct prime_meridian final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
} prime_meridian; } prime_meridian;

View File

@@ -42,7 +42,7 @@ import mp_units.core;
template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min, template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max> MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; };
template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min, template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max> MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
@@ -63,10 +63,10 @@ public:
}; };
template<typename T, auto Min, auto Max> template<typename T, auto Min, auto Max>
inline constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>; constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>;
template<typename T, auto Min, auto Max> template<typename T, auto Min, auto Max>
inline constexpr bool mp_units::treat_as_floating_point<ranged_representation<T, Min, Max>> = constexpr bool mp_units::treat_as_floating_point<ranged_representation<T, Min, Max>> =
mp_units::treat_as_floating_point<T>; mp_units::treat_as_floating_point<T>;
template<typename T, auto Min, auto Max, typename Char> template<typename T, auto Min, auto Max, typename Char>

View File

@@ -40,7 +40,7 @@ import mp_units.core;
#include <mp-units/framework/customization_points.h> #include <mp-units/framework/customization_points.h>
#endif #endif
inline constexpr struct validated_tag { constexpr struct validated_tag {
} validated; } validated;
template<std::movable T, std::predicate<T> Validator> template<std::movable T, std::predicate<T> Validator>
@@ -114,11 +114,10 @@ public:
}; };
template<typename T, typename Validator> template<typename T, typename Validator>
inline constexpr bool mp_units::is_scalar<validated_type<T, Validator>> = mp_units::is_scalar<T>; constexpr bool mp_units::is_scalar<validated_type<T, Validator>> = mp_units::is_scalar<T>;
template<typename T, typename Validator> template<typename T, typename Validator>
inline constexpr bool mp_units::treat_as_floating_point<validated_type<T, Validator>> = constexpr bool mp_units::treat_as_floating_point<validated_type<T, Validator>> = mp_units::treat_as_floating_point<T>;
mp_units::treat_as_floating_point<T>;
template<typename CharT, typename Traits, typename T, typename Validator> template<typename CharT, typename Traits, typename T, typename Validator>

View File

@@ -47,13 +47,13 @@ namespace kalman {
namespace detail { namespace detail {
template<mp_units::Dimension auto... Ds> template<mp_units::Dimension auto... Ds>
inline constexpr bool are_time_derivatives = false; constexpr bool are_time_derivatives = false;
template<mp_units::Dimension auto D> template<mp_units::Dimension auto D>
inline constexpr bool are_time_derivatives<D> = true; constexpr bool are_time_derivatives<D> = true;
template<mp_units::Dimension auto D1, mp_units::Dimension auto D2, mp_units::Dimension auto... Ds> template<mp_units::Dimension auto D1, mp_units::Dimension auto D2, mp_units::Dimension auto... Ds>
inline constexpr bool are_time_derivatives<D1, D2, Ds...> = constexpr bool are_time_derivatives<D1, D2, Ds...> =
(D1 / D2 == mp_units::isq::dim_time) && are_time_derivatives<D2, Ds...>; (D1 / D2 == mp_units::isq::dim_time) && are_time_derivatives<D2, Ds...>;
} // namespace detail } // namespace detail

View File

@@ -40,7 +40,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units; using namespace mp_units;

View File

@@ -40,7 +40,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units; using namespace mp_units;

View File

@@ -40,7 +40,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units; using namespace mp_units;

View File

@@ -132,12 +132,12 @@ private:
} // namespace } // namespace
template<class T> template<class T>
inline constexpr bool mp_units::treat_as_floating_point<measurement<T>> = mp_units::treat_as_floating_point<T>; constexpr bool mp_units::treat_as_floating_point<measurement<T>> = mp_units::treat_as_floating_point<T>;
template<class T> template<class T>
inline constexpr bool mp_units::is_scalar<measurement<T>> = true; constexpr bool mp_units::is_scalar<measurement<T>> = true;
template<class T> template<class T>
inline constexpr bool mp_units::is_vector<measurement<T>> = true; constexpr bool mp_units::is_vector<measurement<T>> = true;
static_assert(mp_units::RepresentationOf<measurement<double>, mp_units::quantity_character::scalar>); static_assert(mp_units::RepresentationOf<measurement<double>, mp_units::quantity_character::scalar>);

View File

@@ -41,7 +41,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
int main() int main()
{ {

View File

@@ -44,7 +44,7 @@ import mp_units;
// types instead of requiring the usage of Linear Algebra library for this simple example // types instead of requiring the usage of Linear Algebra library for this simple example
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {
@@ -58,8 +58,8 @@ QUANTITY_SPEC(horizontal_length, isq::length);
// with a constrained quantity equation // with a constrained quantity equation
QUANTITY_SPEC(horizontal_area, isq::area, horizontal_length* isq::width); QUANTITY_SPEC(horizontal_area, isq::area, horizontal_length* isq::width);
inline constexpr auto g = 1 * si::standard_gravity; constexpr auto g = 1 * si::standard_gravity;
inline constexpr auto air_density = isq::mass_density(1.225 * kg / m3); constexpr auto air_density = isq::mass_density(1.225 * kg / m3);
class StorageTank { class StorageTank {
quantity<horizontal_area[m2]> base_; quantity<horizontal_area[m2]> base_;

View File

@@ -35,7 +35,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
int main() int main()
{ {

View File

@@ -39,7 +39,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {

View File

@@ -53,7 +53,7 @@ struct height_above_ellipsoid_t final : absolute_point_origin<isq::altitude> {
static constexpr earth_gravity_model egm = M; static constexpr earth_gravity_model egm = M;
}; };
template<earth_gravity_model M> template<earth_gravity_model M>
inline constexpr height_above_ellipsoid_t<M> height_above_ellipsoid; // NOLINT(google-readability-casting) constexpr height_above_ellipsoid_t<M> height_above_ellipsoid; // NOLINT(google-readability-casting)
template<earth_gravity_model M> template<earth_gravity_model M>
using hae_altitude = quantity_point<isq::altitude[si::metre], height_above_ellipsoid<M>>; using hae_altitude = quantity_point<isq::altitude[si::metre], height_above_ellipsoid<M>>;
@@ -119,7 +119,7 @@ hae_altitude<M> to_hae(msl_altitude msl, position<long double> pos)
// **** HAL **** // **** HAL ****
// clang-format off // clang-format off
inline constexpr struct height_above_launch final : absolute_point_origin<isq::altitude> {} height_above_launch; constexpr struct height_above_launch final : absolute_point_origin<isq::altitude> {} height_above_launch;
// clang-format on // clang-format on
using hal_altitude = quantity_point<isq::altitude[si::metre], height_above_launch>; using hal_altitude = quantity_point<isq::altitude[si::metre], height_above_launch>;

View File

@@ -122,7 +122,7 @@ public:
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END
template<typename T> template<typename T>
inline constexpr bool is_integer = constexpr bool is_integer =
std::is_integral_v<T> && !std::is_same_v<T, bool> && !std::is_same_v<T, char> && !std::is_same_v<T, wchar_t>; std::is_integral_v<T> && !std::is_same_v<T, bool> && !std::is_same_v<T, char> && !std::is_same_v<T, wchar_t>;
// Converts a character to ASCII. Returns a number > 127 on conversion failure. // Converts a character to ASCII. Returns a number > 127 on conversion failure.

View File

@@ -104,7 +104,7 @@ namespace std {
struct from_range_t { struct from_range_t {
explicit from_range_t() = default; explicit from_range_t() = default;
}; };
inline constexpr from_range_t from_range{}; constexpr from_range_t from_range{};
} // namespace std } // namespace std

View File

@@ -40,32 +40,32 @@ namespace mp_units::detail {
template<std::intmax_t Value> template<std::intmax_t Value>
requires(0 <= Value) && (Value < 10) requires(0 <= Value) && (Value < 10)
inline constexpr basic_fixed_string superscript_number = u8""; constexpr basic_fixed_string superscript_number = u8"";
template<> template<>
inline constexpr basic_fixed_string superscript_number<0> = u8"\u2070"; constexpr basic_fixed_string superscript_number<0> = u8"\u2070";
template<> template<>
inline constexpr basic_fixed_string superscript_number<1> = u8"\u00b9"; constexpr basic_fixed_string superscript_number<1> = u8"\u00b9";
template<> template<>
inline constexpr basic_fixed_string superscript_number<2> = u8"\u00b2"; constexpr basic_fixed_string superscript_number<2> = u8"\u00b2";
template<> template<>
inline constexpr basic_fixed_string superscript_number<3> = u8"\u00b3"; constexpr basic_fixed_string superscript_number<3> = u8"\u00b3";
template<> template<>
inline constexpr basic_fixed_string superscript_number<4> = u8"\u2074"; constexpr basic_fixed_string superscript_number<4> = u8"\u2074";
template<> template<>
inline constexpr basic_fixed_string superscript_number<5> = u8"\u2075"; constexpr basic_fixed_string superscript_number<5> = u8"\u2075";
template<> template<>
inline constexpr basic_fixed_string superscript_number<6> = u8"\u2076"; constexpr basic_fixed_string superscript_number<6> = u8"\u2076";
template<> template<>
inline constexpr basic_fixed_string superscript_number<7> = u8"\u2077"; constexpr basic_fixed_string superscript_number<7> = u8"\u2077";
template<> template<>
inline constexpr basic_fixed_string superscript_number<8> = u8"\u2078"; constexpr basic_fixed_string superscript_number<8> = u8"\u2078";
template<> template<>
inline constexpr basic_fixed_string superscript_number<9> = u8"\u2079"; constexpr basic_fixed_string superscript_number<9> = u8"\u2079";
inline constexpr symbol_text superscript_minus(u8"\u207b", "-"); constexpr symbol_text superscript_minus(u8"\u207b", "-");
inline constexpr symbol_text superscript_prefix(u8"", "^"); constexpr symbol_text superscript_prefix(u8"", "^");
template<std::intmax_t Value> template<std::intmax_t Value>
[[nodiscard]] consteval auto superscript_helper() [[nodiscard]] consteval auto superscript_helper()

View File

@@ -40,10 +40,10 @@ MP_UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF
namespace mp_units::detail { namespace mp_units::detail {
template<typename T> template<typename T>
inline constexpr bool is_type_list = false; constexpr bool is_type_list = false;
template<template<typename...> typename T, typename... Types> template<template<typename...> typename T, typename... Types>
inline constexpr bool is_type_list<T<Types...>> = true; constexpr bool is_type_list<T<Types...>> = true;
template<typename T> template<typename T>
concept TypeList = is_type_list<T>; concept TypeList = is_type_list<T>;
@@ -56,7 +56,7 @@ template<template<typename...> typename List, typename... Types>
struct type_list_size_impl<List<Types...>> : std::integral_constant<std::size_t, sizeof...(Types)> {}; struct type_list_size_impl<List<Types...>> : std::integral_constant<std::size_t, sizeof...(Types)> {};
template<TypeList List> template<TypeList List>
inline constexpr std::size_t type_list_size = type_list_size_impl<List>::value; constexpr std::size_t type_list_size = type_list_size_impl<List>::value;
// map // map
template<typename T, template<typename...> typename To> template<typename T, template<typename...> typename To>

View File

@@ -28,14 +28,14 @@
#if MP_UNITS_API_NO_CRTP #if MP_UNITS_API_NO_CRTP
#define QUANTITY_SPEC(name, ...) \ #define QUANTITY_SPEC(name, ...) \
inline constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \ constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \
} name } name
#else #else
#define QUANTITY_SPEC(name, ...) \ #define QUANTITY_SPEC(name, ...) \
inline constexpr struct name final : ::mp_units::quantity_spec<name, __VA_ARGS__> { \ constexpr struct name final : ::mp_units::quantity_spec<name, __VA_ARGS__> { \
} name } name
#endif #endif

View File

@@ -60,26 +60,26 @@ using conditional = MP_UNITS_TYPENAME detail::conditional_impl<B>::template type
// is_same // is_same
template<class T, class U> template<class T, class U>
inline constexpr bool is_same_v = false; constexpr bool is_same_v = false;
template<class T> template<class T>
inline constexpr bool is_same_v<T, T> = true; constexpr bool is_same_v<T, T> = true;
template<class T, class U> template<class T, class U>
using is_same = std::bool_constant<is_same_v<T, U>>; using is_same = std::bool_constant<is_same_v<T, U>>;
// is_specialization_of // is_specialization_of
template<typename T, template<typename...> typename Type> template<typename T, template<typename...> typename Type>
inline constexpr bool is_specialization_of = false; constexpr bool is_specialization_of = false;
template<typename... Params, template<typename...> typename Type> template<typename... Params, template<typename...> typename Type>
inline constexpr bool is_specialization_of<Type<Params...>, Type> = true; constexpr bool is_specialization_of<Type<Params...>, Type> = true;
template<typename T, template<auto...> typename Type> template<typename T, template<auto...> typename Type>
inline constexpr bool is_specialization_of_v = false; constexpr bool is_specialization_of_v = false;
template<auto... Params, template<auto...> typename Type> template<auto... Params, template<auto...> typename Type>
inline constexpr bool is_specialization_of_v<Type<Params...>, Type> = true; constexpr bool is_specialization_of_v<Type<Params...>, Type> = true;
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END
@@ -92,8 +92,7 @@ void to_base_specialization_of(const volatile Type<Params...>*);
} // namespace detail } // namespace detail
template<typename T, template<typename...> typename Type> template<typename T, template<typename...> typename Type>
inline constexpr bool is_derived_from_specialization_of = constexpr bool is_derived_from_specialization_of = requires(T* t) { detail::to_base_specialization_of<Type>(t); };
requires(T* t) { detail::to_base_specialization_of<Type>(t); };
namespace detail { namespace detail {

View File

@@ -61,10 +61,10 @@ struct absolute_ {
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
template<Reference auto R> template<Reference auto R>
inline constexpr delta_<MP_UNITS_REMOVE_CONST(decltype(R))> delta{}; constexpr delta_<MP_UNITS_REMOVE_CONST(decltype(R))> delta{};
template<Reference auto R> template<Reference auto R>
inline constexpr absolute_<MP_UNITS_REMOVE_CONST(decltype(R))> absolute{}; constexpr absolute_<MP_UNITS_REMOVE_CONST(decltype(R))> absolute{};
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

View File

@@ -50,11 +50,11 @@ MP_UNITS_EXPORT_BEGIN
* @tparam Rep a representation type for which a type trait is defined * @tparam Rep a representation type for which a type trait is defined
*/ */
template<typename Rep> template<typename Rep>
inline constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>; constexpr bool treat_as_floating_point = std::is_floating_point_v<Rep>;
template<typename Rep> template<typename Rep>
requires requires { typename wrapped_type_t<Rep>; } requires requires { typename wrapped_type_t<Rep>; }
inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<wrapped_type_t<Rep>>; constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<wrapped_type_t<Rep>>;
/** /**
* @brief Specifies a type to have a scalar character * @brief Specifies a type to have a scalar character
@@ -62,7 +62,7 @@ inline constexpr bool treat_as_floating_point<Rep> = treat_as_floating_point<wra
* A scalar is a physical quantity that has magnitude but no direction. * A scalar is a physical quantity that has magnitude but no direction.
*/ */
template<typename Rep> template<typename Rep>
inline constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_integral_v<Rep> && !is_same_v<Rep, bool>); constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_integral_v<Rep> && !is_same_v<Rep, bool>);
/** /**
* @brief Specifies a type to have a vector character * @brief Specifies a type to have a vector character
@@ -76,11 +76,11 @@ inline constexpr bool is_scalar = std::is_floating_point_v<Rep> || (std::is_inte
* @code{.cpp} * @code{.cpp}
* template<class T> * template<class T>
* requires mp_units::is_scalar<T> * requires mp_units::is_scalar<T>
* inline constexpr bool mp_units::is_vector<T> = true; * constexpr bool mp_units::is_vector<T> = true;
* @endcode * @endcode
*/ */
template<typename Rep> template<typename Rep>
inline constexpr bool is_vector = false; constexpr bool is_vector = false;
/** /**
* @brief Specifies a type to have a tensor character * @brief Specifies a type to have a tensor character
@@ -91,7 +91,7 @@ inline constexpr bool is_vector = false;
* Similarly to `is_vector` a partial specialization is needed in such cases. * Similarly to `is_vector` a partial specialization is needed in such cases.
*/ */
template<typename Rep> template<typename Rep>
inline constexpr bool is_tensor = false; constexpr bool is_tensor = false;
/** /**
* @brief A type trait that defines zero, one, min, and max for a representation type * @brief A type trait that defines zero, one, min, and max for a representation type

View File

@@ -115,9 +115,9 @@ struct dimension_interface {
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; * constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
* inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time; * constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
* inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass; * constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -184,9 +184,7 @@ struct derived_dimension final : detail::dimension_interface, detail::derived_di
* dimensions are zero. It is a dimension of a quantity of dimension one also known as * dimensions are zero. It is a dimension of a quantity of dimension one also known as
* "dimensionless". * "dimensionless".
*/ */
MP_UNITS_EXPORT inline constexpr struct dimension_one final : MP_UNITS_EXPORT constexpr struct dimension_one final : detail::dimension_interface, detail::derived_dimension_impl<> {
detail::dimension_interface,
detail::derived_dimension_impl<> {
} dimension_one; } dimension_one;
namespace detail { namespace detail {

View File

@@ -53,7 +53,7 @@ template<symbol_text Symbol>
void to_base_specialization_of_base_dimension(const volatile base_dimension<Symbol>*); void to_base_specialization_of_base_dimension(const volatile base_dimension<Symbol>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_base_dimension = constexpr bool is_derived_from_specialization_of_base_dimension =
requires(T* t) { to_base_specialization_of_base_dimension(t); }; requires(T* t) { to_base_specialization_of_base_dimension(t); };
/** /**
@@ -68,16 +68,16 @@ template<typename T>
struct is_dimension_one : std::false_type {}; struct is_dimension_one : std::false_type {};
template<typename T> template<typename T>
inline constexpr bool is_power_of_dim = requires { constexpr bool is_power_of_dim = requires {
requires is_specialization_of_power<T> && requires is_specialization_of_power<T> &&
(BaseDimension<typename T::factor> || is_dimension_one<typename T::factor>::value); (BaseDimension<typename T::factor> || is_dimension_one<typename T::factor>::value);
}; };
template<typename T> template<typename T>
inline constexpr bool is_per_of_dims = false; constexpr bool is_per_of_dims = false;
template<typename... Ts> template<typename... Ts>
inline constexpr bool is_per_of_dims<per<Ts...>> = constexpr bool is_per_of_dims<per<Ts...>> =
(... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || is_power_of_dim<Ts>)); (... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || is_power_of_dim<Ts>));
template<typename T> template<typename T>

View File

@@ -57,37 +57,37 @@ struct per {};
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_per = false; constexpr bool is_specialization_of_per = false;
template<typename... Ts> template<typename... Ts>
inline constexpr bool is_specialization_of_per<per<Ts...>> = true; constexpr bool is_specialization_of_per<per<Ts...>> = true;
template<int Num, int... Den> template<int Num, int... Den>
inline constexpr bool valid_ratio = true; constexpr bool valid_ratio = true;
template<int... Den> template<int... Den>
inline constexpr bool valid_ratio<0, Den...> = false; constexpr bool valid_ratio<0, Den...> = false;
template<int Num> template<int Num>
inline constexpr bool valid_ratio<Num, 0> = false; constexpr bool valid_ratio<Num, 0> = false;
template<> template<>
inline constexpr bool valid_ratio<0, 0> = false; constexpr bool valid_ratio<0, 0> = false;
template<int Num, int... Den> template<int Num, int... Den>
inline constexpr bool positive_ratio = gt_zero<Num>; constexpr bool positive_ratio = gt_zero<Num>;
template<int Num, int Den> template<int Num, int Den>
inline constexpr bool positive_ratio<Num, Den> = gt_zero<Num * Den>; constexpr bool positive_ratio<Num, Den> = gt_zero<Num * Den>;
template<int Num, int... Den> template<int Num, int... Den>
inline constexpr bool ratio_one = false; constexpr bool ratio_one = false;
template<> template<>
inline constexpr bool ratio_one<1> = true; constexpr bool ratio_one<1> = true;
template<int N> template<int N>
inline constexpr bool ratio_one<N, N> = true; constexpr bool ratio_one<N, N> = true;
} // namespace detail } // namespace detail
@@ -127,10 +127,10 @@ using expr_type = MP_UNITS_TYPENAME detail::expr_type_impl<T>::type;
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_power = false; constexpr bool is_specialization_of_power = false;
template<typename F, int... Ints> template<typename F, int... Ints>
inline constexpr bool is_specialization_of_power<power<F, Ints...>> = true; constexpr bool is_specialization_of_power<power<F, Ints...>> = true;
template<typename T, ratio R> template<typename T, ratio R>
consteval auto power_or_T_impl() consteval auto power_or_T_impl()
@@ -509,10 +509,10 @@ concept expr_type_projectable = (requires { typename Proj<T>; } ||
(is_specialization_of_power<T> && requires { typename Proj<typename T::factor>; })); (is_specialization_of_power<T> && requires { typename Proj<typename T::factor>; }));
template<typename T, template<typename> typename Proj> template<typename T, template<typename> typename Proj>
inline constexpr bool expr_projectable_impl = false; constexpr bool expr_projectable_impl = false;
template<typename... Ts, template<typename> typename Proj> template<typename... Ts, template<typename> typename Proj>
inline constexpr bool expr_projectable_impl<type_list<Ts...>, Proj> = (... && expr_type_projectable<Ts, Proj>); constexpr bool expr_projectable_impl<type_list<Ts...>, Proj> = (... && expr_type_projectable<Ts, Proj>);
template<typename T, template<typename> typename Proj> template<typename T, template<typename> typename Proj>
concept expr_projectable = requires { concept expr_projectable = requires {

View File

@@ -59,10 +59,10 @@ using factorizer = wheel_factorizer<4>;
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_magnitude = false; constexpr bool is_magnitude = false;
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_magnitude = false; constexpr bool is_specialization_of_magnitude = false;
} // namespace detail } // namespace detail
@@ -87,7 +87,7 @@ concept Magnitude = detail::is_magnitude<T>;
// void to_base_specialization_of_constant(const volatile constant<V>*); // void to_base_specialization_of_constant(const volatile constant<V>*);
// template<typename T> // template<typename T>
// inline constexpr bool is_derived_from_specialization_of_constant = // constexpr bool is_derived_from_specialization_of_constant =
// requires(T * t) { to_base_specialization_of_constant(t); }; // requires(T * t) { to_base_specialization_of_constant(t); };
// } // namespace detail // } // namespace detail
@@ -142,7 +142,7 @@ concept Magnitude = detail::is_magnitude<T>;
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_named_magnitude = Magnitude<T> && !detail::is_specialization_of_magnitude<T>; constexpr bool is_named_magnitude = Magnitude<T> && !detail::is_specialization_of_magnitude<T>;
} }
@@ -178,10 +178,10 @@ struct power_v {
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_power_v = false; constexpr bool is_specialization_of_power_v = false;
template<auto V, int... Ints> template<auto V, int... Ints>
inline constexpr bool is_specialization_of_power_v<power_v<V, Ints...>> = true; constexpr bool is_specialization_of_power_v<power_v<V, Ints...>> = true;
} // namespace detail } // namespace detail
@@ -572,13 +572,13 @@ namespace detail {
// } // }
// template<MagnitudeSpec auto... Elements> // template<MagnitudeSpec auto... Elements>
// inline constexpr bool all_elements_valid = (is_valid_element(Elements) && ...); // constexpr bool all_elements_valid = (is_valid_element(Elements) && ...);
// template<MagnitudeSpec auto... Elements> // template<MagnitudeSpec auto... Elements>
// inline constexpr bool all_elements_in_order = strictly_increasing(get_base_value(Elements)...); // constexpr bool all_elements_in_order = strictly_increasing(get_base_value(Elements)...);
// template<MagnitudeSpec auto... Elements> // template<MagnitudeSpec auto... Elements>
// inline constexpr bool is_element_pack_valid = all_elements_valid<Elements...> && all_elements_in_order<Elements...>; // constexpr bool is_element_pack_valid = all_elements_valid<Elements...> && all_elements_in_order<Elements...>;
[[nodiscard]] consteval bool is_rational(MagnitudeSpec auto element) [[nodiscard]] consteval bool is_rational(MagnitudeSpec auto element)
{ {
@@ -707,15 +707,14 @@ template<auto... Ms>
void to_base_specialization_of_magnitude(const volatile magnitude<Ms...>*); void to_base_specialization_of_magnitude(const volatile magnitude<Ms...>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_magnitude = constexpr bool is_derived_from_specialization_of_magnitude = requires(T* t) { to_base_specialization_of_magnitude(t); };
requires(T* t) { to_base_specialization_of_magnitude(t); };
template<typename T> template<typename T>
requires is_derived_from_specialization_of_magnitude<T> requires is_derived_from_specialization_of_magnitude<T>
inline constexpr bool is_magnitude<T> = true; constexpr bool is_magnitude<T> = true;
template<auto... Ms> template<auto... Ms>
inline constexpr bool is_specialization_of_magnitude<magnitude<Ms...>> = true; constexpr bool is_specialization_of_magnitude<magnitude<Ms...>> = true;
} // namespace detail } // namespace detail
@@ -726,12 +725,12 @@ MP_UNITS_EXPORT_BEGIN
*/ */
#if MP_UNITS_COMP_CLANG #if MP_UNITS_COMP_CLANG
inline constexpr struct mag_pi : magnitude<mag_value{std::numbers::pi_v<long double>}> { constexpr struct mag_pi : magnitude<mag_value{std::numbers::pi_v<long double>}> {
} mag_pi; } mag_pi;
#else #else
inline constexpr struct mag_pi : magnitude<std::numbers::pi_v<long double>> { constexpr struct mag_pi : magnitude<std::numbers::pi_v<long double>> {
} mag_pi; } mag_pi;
#endif #endif
@@ -882,7 +881,7 @@ using common_magnitude_type = decltype(common_magnitude_type_impl(M));
// //
// WARNING: The program behaviour will be undefined if you provide a wrong answer, so check your math! // WARNING: The program behaviour will be undefined if you provide a wrong answer, so check your math!
MP_UNITS_EXPORT template<std::intmax_t N> MP_UNITS_EXPORT template<std::intmax_t N>
inline constexpr std::optional<std::intmax_t> known_first_factor = std::nullopt; constexpr std::optional<std::intmax_t> known_first_factor = std::nullopt;
namespace detail { namespace detail {
@@ -915,7 +914,7 @@ struct prime_factorization<1> {
}; };
template<std::intmax_t N> template<std::intmax_t N>
inline constexpr auto prime_factorization_v = prime_factorization<N>::value; constexpr auto prime_factorization_v = prime_factorization<N>::value;
} // namespace detail } // namespace detail
@@ -927,18 +926,18 @@ inline constexpr auto prime_factorization_v = prime_factorization<N>::value;
*/ */
MP_UNITS_EXPORT template<std::intmax_t V> MP_UNITS_EXPORT template<std::intmax_t V>
requires detail::gt_zero<V> requires detail::gt_zero<V>
inline constexpr Magnitude auto mag = detail::prime_factorization_v<V>; constexpr Magnitude auto mag = detail::prime_factorization_v<V>;
MP_UNITS_EXPORT template<std::intmax_t N, std::intmax_t D> MP_UNITS_EXPORT template<std::intmax_t N, std::intmax_t D>
requires detail::gt_zero<N> requires detail::gt_zero<N>
inline constexpr Magnitude auto mag_ratio = detail::prime_factorization_v<N> / detail::prime_factorization_v<D>; constexpr Magnitude auto mag_ratio = detail::prime_factorization_v<N> / detail::prime_factorization_v<D>;
/** /**
* @brief Create a Magnitude which is some rational number raised to a rational power. * @brief Create a Magnitude which is some rational number raised to a rational power.
*/ */
MP_UNITS_EXPORT template<std::intmax_t Base, std::intmax_t Pow> MP_UNITS_EXPORT template<std::intmax_t Base, std::intmax_t Pow>
requires detail::gt_zero<Base> requires detail::gt_zero<Base>
inline constexpr Magnitude auto mag_power = pow<Pow>(mag<Base>); constexpr Magnitude auto mag_power = pow<Pow>(mag<Base>);
namespace detail { namespace detail {
@@ -960,7 +959,7 @@ template<typename T, auto... Ms>
return integer_part((detail::abs(power_of_2) < detail::abs(power_of_5)) ? power_of_2 : power_of_5); return integer_part((detail::abs(power_of_2) < detail::abs(power_of_5)) ? power_of_2 : power_of_5);
} }
inline constexpr symbol_text base_multiplier(u8"× 10", "x 10"); constexpr symbol_text base_multiplier(u8"× 10", "x 10");
template<Magnitude auto M> template<Magnitude auto M>
[[nodiscard]] consteval auto magnitude_text() [[nodiscard]] consteval auto magnitude_text()

View File

@@ -40,8 +40,7 @@ template<auto R, typename Rep>
void to_base_specialization_of_quantity(const volatile quantity<R, Rep>*); void to_base_specialization_of_quantity(const volatile quantity<R, Rep>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_quantity = constexpr bool is_derived_from_specialization_of_quantity = requires(T* t) { to_base_specialization_of_quantity(t); };
requires(T* t) { to_base_specialization_of_quantity(t); };
} // namespace detail } // namespace detail

View File

@@ -43,7 +43,7 @@ namespace mp_units {
namespace detail { namespace detail {
template<PointOrigin PO> template<PointOrigin PO>
inline constexpr bool is_specialization_of_zeroth_point_origin = false; constexpr bool is_specialization_of_zeroth_point_origin = false;
template<PointOrigin PO> template<PointOrigin PO>
[[nodiscard]] consteval bool is_zeroth_point_origin(PO) [[nodiscard]] consteval bool is_zeroth_point_origin(PO)
@@ -130,12 +130,12 @@ template<QuantitySpec auto QS>
struct zeroth_point_origin_ final : absolute_point_origin<QS> {}; struct zeroth_point_origin_ final : absolute_point_origin<QS> {};
MP_UNITS_EXPORT template<QuantitySpec auto QS> MP_UNITS_EXPORT template<QuantitySpec auto QS>
inline constexpr zeroth_point_origin_<QS> zeroth_point_origin; constexpr zeroth_point_origin_<QS> zeroth_point_origin;
namespace detail { namespace detail {
template<auto QS> template<auto QS>
inline constexpr bool is_specialization_of_zeroth_point_origin<zeroth_point_origin_<QS>> = true; constexpr bool is_specialization_of_zeroth_point_origin<zeroth_point_origin_<QS>> = true;
} // namespace detail } // namespace detail

View File

@@ -38,13 +38,13 @@ struct absolute_point_origin;
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_quantity_point = false; constexpr bool is_quantity_point = false;
template<auto Q> template<auto Q>
void to_base_specialization_of_absolute_point_origin(const volatile absolute_point_origin<Q>*); void to_base_specialization_of_absolute_point_origin(const volatile absolute_point_origin<Q>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_absolute_point_origin = constexpr bool is_derived_from_specialization_of_absolute_point_origin =
requires(T* t) { to_base_specialization_of_absolute_point_origin(t); }; requires(T* t) { to_base_specialization_of_absolute_point_origin(t); };
} // namespace detail } // namespace detail
@@ -66,7 +66,7 @@ template<auto QP>
void to_base_specialization_of_relative_point_origin(const volatile relative_point_origin<QP>*); void to_base_specialization_of_relative_point_origin(const volatile relative_point_origin<QP>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_relative_point_origin = constexpr bool is_derived_from_specialization_of_relative_point_origin =
requires(T* t) { to_base_specialization_of_relative_point_origin(t); }; requires(T* t) { to_base_specialization_of_relative_point_origin(t); };
struct point_origin_interface; struct point_origin_interface;
@@ -99,12 +99,12 @@ template<auto R, auto PO, typename Rep>
void to_base_specialization_of_quantity_point(const volatile quantity_point<R, PO, Rep>*); void to_base_specialization_of_quantity_point(const volatile quantity_point<R, PO, Rep>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_quantity_point = constexpr bool is_derived_from_specialization_of_quantity_point =
requires(T* t) { to_base_specialization_of_quantity_point(t); }; requires(T* t) { to_base_specialization_of_quantity_point(t); };
template<typename T> template<typename T>
requires is_derived_from_specialization_of_quantity_point<T> requires is_derived_from_specialization_of_quantity_point<T>
inline constexpr bool is_quantity_point<T> = true; constexpr bool is_quantity_point<T> = true;
template<PointOrigin PO1, PointOrigin PO2> template<PointOrigin PO1, PointOrigin PO2>
[[nodiscard]] consteval bool same_absolute_point_origins(PO1 po1, PO2 po2) [[nodiscard]] consteval bool same_absolute_point_origins(PO1 po1, PO2 po2)

View File

@@ -189,7 +189,7 @@ struct quantity_spec_interface : quantity_spec_interface_base {
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
inline constexpr struct is_kind { constexpr struct is_kind {
} is_kind; } is_kind;
/** /**
@@ -235,13 +235,13 @@ MP_UNITS_EXPORT_END
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; * constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
* inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass; * constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
* inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time; * constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
* *
* inline constexpr struct length final : quantity_spec<dim_length> {} length; * constexpr struct length final : quantity_spec<dim_length> {} length;
* inline constexpr struct mass final : quantity_spec<dim_mass> {} mass; * constexpr struct mass final : quantity_spec<dim_mass> {} mass;
* inline constexpr struct time final : quantity_spec<dim_time> {} time; * constexpr struct time final : quantity_spec<dim_time> {} time;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -280,12 +280,12 @@ struct quantity_spec<Self, Dim, Args...> : detail::quantity_spec_interface<Self>
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct area final : quantity_spec<pow<2>(length)> {} area; * constexpr struct area final : quantity_spec<pow<2>(length)> {} area;
* inline constexpr struct volume final : quantity_spec<pow<3>(length)> {} volume; * constexpr struct volume final : quantity_spec<pow<3>(length)> {} volume;
* inline constexpr struct velocity final : quantity_spec<position_vector / duration> {} velocity; * constexpr struct velocity final : quantity_spec<position_vector / duration> {} velocity;
* inline constexpr struct speed final : quantity_spec<length / time> {} speed; * constexpr struct speed final : quantity_spec<length / time> {} speed;
* inline constexpr struct force final : quantity_spec<mass * acceleration, quantity_character::vector> {} force; * constexpr struct force final : quantity_spec<mass * acceleration, quantity_character::vector> {} force;
* inline constexpr struct power final : quantity_spec<force * velocity, quantity_character::scalar> {} power; * constexpr struct power final : quantity_spec<force * velocity, quantity_character::scalar> {} power;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -335,10 +335,10 @@ struct propagate_equation<Q, true> {
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct width final : quantity_spec<length> {} width; * constexpr struct width final : quantity_spec<length> {} width;
* inline constexpr struct height final : quantity_spec<length> {} height; * constexpr struct height final : quantity_spec<length> {} height;
* inline constexpr struct diameter final : quantity_spec<width> {} diameter; * constexpr struct diameter final : quantity_spec<width> {} diameter;
* inline constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector; * constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -396,10 +396,10 @@ struct quantity_spec<Self, QS, Args...> : detail::propagate_equation<QS>, detail
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure; * constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure;
* inline constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity; * constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity;
* inline constexpr struct weight final : quantity_spec<force, mass * acceleration_of_free_fall> {} weight; * constexpr struct weight final : quantity_spec<force, mass * acceleration_of_free_fall> {} weight;
* inline constexpr struct kinetic_energy final : quantity_spec<mechanical_energy, mass * pow<2>(speed)> {} kinetic_energy; * constexpr struct kinetic_energy final : quantity_spec<mechanical_energy, mass * pow<2>(speed)> {} kinetic_energy;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -556,7 +556,7 @@ struct kind_of_<Q> final : quantity_spec<kind_of_<Q>, Q{}>::_base_type_ {
MP_UNITS_EXPORT template<detail::QuantitySpecWithNoSpecifiers auto Q> MP_UNITS_EXPORT template<detail::QuantitySpecWithNoSpecifiers auto Q>
requires detail::SameQuantitySpec<detail::get_kind_tree_root(Q), Q> requires detail::SameQuantitySpec<detail::get_kind_tree_root(Q), Q>
inline constexpr kind_of_<MP_UNITS_REMOVE_CONST(decltype(Q))> kind_of; constexpr kind_of_<MP_UNITS_REMOVE_CONST(decltype(Q))> kind_of;
namespace detail { namespace detail {

View File

@@ -53,10 +53,10 @@ struct kind_of_;
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_kind_of = false; constexpr bool is_specialization_of_kind_of = false;
template<typename Q> template<typename Q>
inline constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true; constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true;
template<typename T> template<typename T>
concept QuantityKindSpec = is_specialization_of_kind_of<T>; concept QuantityKindSpec = is_specialization_of_kind_of<T>;
@@ -70,7 +70,7 @@ void to_base_specialization_of_quantity_spec(const volatile quantity_spec<T, Arg
#endif #endif
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_quantity_spec = constexpr bool is_derived_from_specialization_of_quantity_spec =
requires(T* t) { to_base_specialization_of_quantity_spec(t); }; requires(T* t) { to_base_specialization_of_quantity_spec(t); };
/** /**
@@ -86,16 +86,16 @@ template<typename T>
struct is_dimensionless : std::false_type {}; struct is_dimensionless : std::false_type {};
template<typename T> template<typename T>
inline constexpr bool is_power_of_quantity_spec = requires { constexpr bool is_power_of_quantity_spec = requires {
requires is_specialization_of_power<T> && requires is_specialization_of_power<T> &&
(NamedQuantitySpec<typename T::factor> || is_dimensionless<typename T::factor>::value); (NamedQuantitySpec<typename T::factor> || is_dimensionless<typename T::factor>::value);
}; };
template<typename T> template<typename T>
inline constexpr bool is_per_of_quantity_specs = false; constexpr bool is_per_of_quantity_specs = false;
template<typename... Ts> template<typename... Ts>
inline constexpr bool is_per_of_quantity_specs<per<Ts...>> = constexpr bool is_per_of_quantity_specs<per<Ts...>> =
(... && (NamedQuantitySpec<Ts> || is_dimensionless<Ts>::value || is_power_of_quantity_spec<Ts>)); (... && (NamedQuantitySpec<Ts> || is_dimensionless<Ts>::value || is_power_of_quantity_spec<Ts>));
template<typename T> template<typename T>

View File

@@ -45,15 +45,15 @@ namespace mp_units {
* @code{.cpp} * @code{.cpp}
* // hypothetical natural system of units for c=1 * // hypothetical natural system of units for c=1
* *
* inline constexpr struct second final : named_unit<"s"> {} second; * constexpr struct second final : named_unit<"s"> {} second;
* inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute; * constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
* inline constexpr struct gram final : named_unit<"g"> {} gram; * constexpr struct gram final : named_unit<"g"> {} gram;
* inline constexpr auto kilogram = si::kilo<gram>; * constexpr auto kilogram = si::kilo<gram>;
* *
* inline constexpr struct time : system_reference<isq::time, second> {} time; * constexpr struct time : system_reference<isq::time, second> {} time;
* inline constexpr struct length : system_reference<isq::length, second> {} length; * constexpr struct length : system_reference<isq::length, second> {} length;
* inline constexpr struct speed : system_reference<isq::speed, second / second> {} speed; * constexpr struct speed : system_reference<isq::speed, second / second> {} speed;
* inline constexpr struct force : system_reference<isq::force, kilogram / second> {} force; * constexpr struct force : system_reference<isq::force, kilogram / second> {} force;
* @endcode * @endcode
* *
* @tparam Q quantity for which a unit is being assigned * @tparam Q quantity for which a unit is being assigned

View File

@@ -64,7 +64,7 @@ template<Magnitude auto M, Unit U>
struct scaled_unit_impl; struct scaled_unit_impl;
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_scaled_unit = false; constexpr bool is_specialization_of_scaled_unit = false;
template<DerivedUnitExpr... Expr> template<DerivedUnitExpr... Expr>
struct derived_unit_impl; struct derived_unit_impl;
@@ -241,7 +241,7 @@ struct scaled_unit final : detail::scaled_unit_impl<M, U> {};
namespace detail { namespace detail {
template<auto M, Unit U> template<auto M, Unit U>
inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true; constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true;
} // namespace detail } // namespace detail
@@ -256,12 +256,12 @@ inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true
* For example: * For example:
* *
* @code{.cpp} * @code{.cpp}
* inline constexpr struct second final : named_unit<"s", kind_of<time>> {} second; * constexpr struct second final : named_unit<"s", kind_of<time>> {} second;
* inline constexpr struct metre final : named_unit<"m", kind_of<length> {} metre; * constexpr struct metre final : named_unit<"m", kind_of<length> {} metre;
* inline constexpr struct hertz final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz; * constexpr struct hertz final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
* inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; * constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
* inline constexpr struct degree_Celsius final : named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} * constexpr struct degree_Celsius final : named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {}
* degree_Celsius; inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute; * degree_Celsius; constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
* @endcode * @endcode
* *
* @note A common convention in this library is to assign the same name for a type and an object of this type. * @note A common convention in this library is to assign the same name for a type and an object of this type.
@@ -386,9 +386,9 @@ struct named_unit<Symbol, U, QS, PO> : decltype(U)::_base_type_ {
* struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U> {}; * struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U> {};
* *
* template<PrefixableUnit auto U> * template<PrefixableUnit auto U>
* inline constexpr kilo_<U> kilo; * constexpr kilo_<U> kilo;
* *
* inline constexpr auto kilogram = si::kilo<gram>; * constexpr auto kilogram = si::kilo<gram>;
* @endcode * @endcode
* *
* @tparam Symbol a prefix text to prepend to a unit symbol * @tparam Symbol a prefix text to prepend to a unit symbol
@@ -468,7 +468,7 @@ struct derived_unit final : detail::derived_unit_impl<Expr...> {};
* Unit of a dimensionless quantity. * Unit of a dimensionless quantity.
*/ */
// clang-format off // clang-format off
MP_UNITS_EXPORT inline constexpr struct one final : detail::derived_unit_impl<> {} one; MP_UNITS_EXPORT constexpr struct one final : detail::derived_unit_impl<> {} one;
// clang-format on // clang-format on
namespace detail { namespace detail {
@@ -534,10 +534,10 @@ template<Unit T, typename... Expr>
} }
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_derived_unit = false; constexpr bool is_specialization_of_derived_unit = false;
template<typename... Expr> template<typename... Expr>
inline constexpr bool is_specialization_of_derived_unit<derived_unit<Expr...>> = true; constexpr bool is_specialization_of_derived_unit<derived_unit<Expr...>> = true;
} // namespace detail } // namespace detail
@@ -611,10 +611,10 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
// common dimensionless units // common dimensionless units
// clang-format off // clang-format off
inline constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent; constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
inline constexpr struct per_mille final : named_unit<symbol_text{u8"", "%o"}, mag_ratio<1, 1000> * one> {} per_mille; constexpr struct per_mille final : named_unit<symbol_text{u8"", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
inline constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million; constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
inline constexpr auto ppm = parts_per_million; constexpr auto ppm = parts_per_million;
// clang-format on // clang-format on
@@ -675,14 +675,14 @@ template<Unit U1, Unit U2>
* be provided. * be provided.
*/ */
template<Unit auto U> template<Unit auto U>
inline constexpr bool space_before_unit_symbol = true; constexpr bool space_before_unit_symbol = true;
template<> template<>
inline constexpr bool space_before_unit_symbol<one> = false; constexpr bool space_before_unit_symbol<one> = false;
template<> template<>
inline constexpr bool space_before_unit_symbol<percent> = false; constexpr bool space_before_unit_symbol<percent> = false;
template<> template<>
inline constexpr bool space_before_unit_symbol<per_mille> = false; constexpr bool space_before_unit_symbol<per_mille> = false;
// get_unit_symbol // get_unit_symbol

View File

@@ -59,7 +59,7 @@ template<symbol_text Symbol, auto... Args>
void to_base_specialization_of_named_unit(const volatile named_unit<Symbol, Args...>*); void to_base_specialization_of_named_unit(const volatile named_unit<Symbol, Args...>*);
template<typename T> template<typename T>
inline constexpr bool is_derived_from_specialization_of_named_unit = constexpr bool is_derived_from_specialization_of_named_unit =
requires(T* t) { to_base_specialization_of_named_unit(t); }; requires(T* t) { to_base_specialization_of_named_unit(t); };
} // namespace detail } // namespace detail
@@ -73,14 +73,13 @@ concept PrefixableUnit = Unit<T> && detail::is_derived_from_specialization_of_na
namespace detail { namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_power_of_unit = constexpr bool is_power_of_unit = requires { requires is_specialization_of_power<T> && Unit<typename T::factor>; };
requires { requires is_specialization_of_power<T> && Unit<typename T::factor>; };
template<typename T> template<typename T>
inline constexpr bool is_per_of_units = false; constexpr bool is_per_of_units = false;
template<typename... Ts> template<typename... Ts>
inline constexpr bool is_per_of_units<per<Ts...>> = (... && (Unit<Ts> || is_power_of_unit<Ts>)); constexpr bool is_per_of_units<per<Ts...>> = (... && (Unit<Ts> || is_power_of_unit<Ts>));
template<typename T> template<typename T>
concept DerivedUnitExpr = Unit<T> || detail::is_power_of_unit<T> || detail::is_per_of_units<T>; concept DerivedUnitExpr = Unit<T> || detail::is_power_of_unit<T> || detail::is_per_of_units<T>;

View File

@@ -184,7 +184,7 @@ template<Unit auto ToU, Representation ToRep, typename QP>
* Implicit conversions between quantities of different types are allowed only for "safe" * Implicit conversions between quantities of different types are allowed only for "safe"
* (e.g. non-truncating) conversion. In truncating cases an explicit cast have to be used. * (e.g. non-truncating) conversion. In truncating cases an explicit cast have to be used.
* *
* inline constexpr struct A : absolute_point_origin<A, isq::distance> A; * constexpr struct A : absolute_point_origin<A, isq::distance> A;
* *
* using ToQ = quantity<mm, int>; * using ToQ = quantity<mm, int>;
* auto qp = value_cast<ToQ>(quantity_point{1.23 * m}); * auto qp = value_cast<ToQ>(quantity_point{1.23 * m});
@@ -210,8 +210,8 @@ template<Quantity ToQ, typename QP>
* Implicit conversions between quantities of different types are allowed only for "safe" * Implicit conversions between quantities of different types are allowed only for "safe"
* (e.g. non-truncating) conversion. In truncating cases an explicit cast have to be used. * (e.g. non-truncating) conversion. In truncating cases an explicit cast have to be used.
* *
* inline constexpr struct A : absolute_point_origin<A, isq::distance> A; * constexpr struct A : absolute_point_origin<A, isq::distance> A;
* inline constexpr struct B : relative_point_origin<A + 1*m> B; * constexpr struct B : relative_point_origin<A + 1*m> B;
* *
* using ToQP = quantity_point<mm, B, int>; * using ToQP = quantity_point<mm, B, int>;
* auto qp = value_cast<ToQP>(quantity_point{1.23 * m}); * auto qp = value_cast<ToQP>(quantity_point{1.23 * m});

View File

@@ -36,34 +36,34 @@ namespace mp_units {
namespace angular { namespace angular {
// clang-format off // clang-format off
inline constexpr struct dim_angle final : base_dimension<"A"> {} dim_angle; constexpr struct dim_angle final : base_dimension<"A"> {} dim_angle;
QUANTITY_SPEC(angle, dim_angle); QUANTITY_SPEC(angle, dim_angle);
QUANTITY_SPEC(solid_angle, pow<2>(angle)); QUANTITY_SPEC(solid_angle, pow<2>(angle));
inline constexpr struct radian final : named_unit<"rad", kind_of<angle>> {} radian; constexpr struct radian final : named_unit<"rad", kind_of<angle>> {} radian;
inline constexpr struct revolution final : named_unit<"rev", mag<2> * mag_pi * radian> {} revolution; constexpr struct revolution final : named_unit<"rev", mag<2> * mag_pi * radian> {} revolution;
inline constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_ratio<1, 360> * revolution> {} degree; constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_ratio<1, 360> * revolution> {} degree;
inline constexpr struct gradian final : named_unit<symbol_text{u8"", "grad"}, mag_ratio<1, 400> * revolution> {} gradian; constexpr struct gradian final : named_unit<symbol_text{u8"", "grad"}, mag_ratio<1, 400> * revolution> {} gradian;
inline constexpr struct steradian final : named_unit<"sr", square(radian)> {} steradian; constexpr struct steradian final : named_unit<"sr", square(radian)> {} steradian;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto rad = radian; constexpr auto rad = radian;
inline constexpr auto rev = revolution; constexpr auto rev = revolution;
inline constexpr auto deg = degree; constexpr auto deg = degree;
inline constexpr auto grad = gradian; constexpr auto grad = gradian;
inline constexpr auto sr = steradian; constexpr auto sr = steradian;
inline constexpr auto rad2 = square(radian); constexpr auto rad2 = square(radian);
inline constexpr auto deg2 = square(degree); constexpr auto deg2 = square(degree);
} // namespace unit_symbols } // namespace unit_symbols
} // namespace angular } // namespace angular
template<> template<>
inline constexpr bool space_before_unit_symbol<angular::degree> = false; constexpr bool space_before_unit_symbol<angular::degree> = false;
template<> template<>
inline constexpr bool space_before_unit_symbol<angular::gradian> = false; constexpr bool space_before_unit_symbol<angular::gradian> = false;
} // namespace mp_units } // namespace mp_units

View File

@@ -35,35 +35,35 @@ MP_UNITS_EXPORT
namespace mp_units::cgs { namespace mp_units::cgs {
// clang-format off // clang-format off
inline constexpr auto centimetre = si::centi<si::metre>; constexpr auto centimetre = si::centi<si::metre>;
inline constexpr auto gram = si::gram; constexpr auto gram = si::gram;
inline constexpr auto second = si::second; constexpr auto second = si::second;
inline constexpr struct gal final : named_unit<"Gal", centimetre / square(second)> {} gal; constexpr struct gal final : named_unit<"Gal", centimetre / square(second)> {} gal;
inline constexpr struct dyne final : named_unit<"dyn", gram * centimetre / square(second)> {} dyne; constexpr struct dyne final : named_unit<"dyn", gram * centimetre / square(second)> {} dyne;
inline constexpr struct erg final : named_unit<"erg", dyne * centimetre> {} erg; constexpr struct erg final : named_unit<"erg", dyne * centimetre> {} erg;
inline constexpr struct barye final : named_unit<"Ba", gram / (centimetre * square(second))> {} barye; constexpr struct barye final : named_unit<"Ba", gram / (centimetre * square(second))> {} barye;
inline constexpr struct poise final : named_unit<"P", gram / (centimetre * second)> {} poise; constexpr struct poise final : named_unit<"P", gram / (centimetre * second)> {} poise;
inline constexpr struct stokes final : named_unit<"St", square(centimetre) / second> {} stokes; constexpr struct stokes final : named_unit<"St", square(centimetre) / second> {} stokes;
inline constexpr struct kayser final : named_unit<"K", one / centimetre> {} kayser; constexpr struct kayser final : named_unit<"K", one / centimetre> {} kayser;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto cm = centimetre; constexpr auto cm = centimetre;
inline constexpr auto g = gram; constexpr auto g = gram;
inline constexpr auto s = second; constexpr auto s = second;
inline constexpr auto Gal = gal; constexpr auto Gal = gal;
inline constexpr auto dyn = dyne; constexpr auto dyn = dyne;
inline constexpr auto Ba = barye; constexpr auto Ba = barye;
inline constexpr auto P = poise; constexpr auto P = poise;
inline constexpr auto St = stokes; constexpr auto St = stokes;
inline constexpr auto K = kayser; constexpr auto K = kayser;
// commonly used squared and cubic units // commonly used squared and cubic units
inline constexpr auto cm2 = square(centimetre); constexpr auto cm2 = square(centimetre);
inline constexpr auto cm3 = cubic(centimetre); constexpr auto cm3 = cubic(centimetre);
inline constexpr auto s2 = square(second); constexpr auto s2 = square(second);
inline constexpr auto s3 = cubic(second); constexpr auto s3 = cubic(second);
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -36,7 +36,7 @@ MP_UNITS_EXPORT
namespace mp_units { namespace mp_units {
template<> template<>
inline constexpr std::optional<std::intmax_t> known_first_factor<334'524'384'739> = 334'524'384'739; constexpr std::optional<std::intmax_t> known_first_factor<334'524'384'739> = 334'524'384'739;
namespace hep { namespace hep {
@@ -49,64 +49,64 @@ using si::electronvolt;
// effective cross-sectional area according to EU council directive 80/181/EEC // effective cross-sectional area according to EU council directive 80/181/EEC
// https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:01980L0181-20090527#page=10 // https://eur-lex.europa.eu/legal-content/EN/TXT/PDF/?uri=CELEX:01980L0181-20090527#page=10
// https://www.fedlex.admin.ch/eli/cc/1994/3109_3109_3109/de // https://www.fedlex.admin.ch/eli/cc/1994/3109_3109_3109/de
inline constexpr struct barn final : named_unit<"b", mag_power<10, -28> * square(si::metre)> {} barn; constexpr struct barn final : named_unit<"b", mag_power<10, -28> * square(si::metre)> {} barn;
// mass // mass
inline constexpr struct electron_mass final : named_unit<"m_e", mag_ratio<9'109'383'701'528, 1'000'000'000'000> * mag_power<10, -31> * si::kilogram> {} electron_mass; constexpr struct electron_mass final : named_unit<"m_e", mag_ratio<9'109'383'701'528, 1'000'000'000'000> * mag_power<10, -31> * si::kilogram> {} electron_mass;
inline constexpr struct proton_mass final : named_unit<"m_p", mag_ratio<1'672'621'923'695, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} proton_mass; constexpr struct proton_mass final : named_unit<"m_p", mag_ratio<1'672'621'923'695, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} proton_mass;
inline constexpr struct neutron_mass final : named_unit<"m_n", mag_ratio<1'674'927'498'049, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} neutron_mass; constexpr struct neutron_mass final : named_unit<"m_n", mag_ratio<1'674'927'498'049, 1'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} neutron_mass;
// speed // speed
inline constexpr auto speed_of_light = si::si2019::speed_of_light_in_vacuum; constexpr auto speed_of_light = si::si2019::speed_of_light_in_vacuum;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
using si::unit_symbols::eV; using si::unit_symbols::eV;
inline constexpr auto qeV = si::quecto<electronvolt>; constexpr auto qeV = si::quecto<electronvolt>;
inline constexpr auto reV = si::ronto<electronvolt>; constexpr auto reV = si::ronto<electronvolt>;
inline constexpr auto yeV = si::yocto<electronvolt>; constexpr auto yeV = si::yocto<electronvolt>;
inline constexpr auto zeV = si::zepto<electronvolt>; constexpr auto zeV = si::zepto<electronvolt>;
inline constexpr auto aeV = si::atto<electronvolt>; constexpr auto aeV = si::atto<electronvolt>;
inline constexpr auto feV = si::femto<electronvolt>; constexpr auto feV = si::femto<electronvolt>;
inline constexpr auto peV = si::pico<electronvolt>; constexpr auto peV = si::pico<electronvolt>;
inline constexpr auto neV = si::nano<electronvolt>; constexpr auto neV = si::nano<electronvolt>;
inline constexpr auto ueV = si::micro<electronvolt>; constexpr auto ueV = si::micro<electronvolt>;
inline constexpr auto meV = si::milli<electronvolt>; constexpr auto meV = si::milli<electronvolt>;
inline constexpr auto ceV = si::centi<electronvolt>; constexpr auto ceV = si::centi<electronvolt>;
inline constexpr auto deV = si::deci<electronvolt>; constexpr auto deV = si::deci<electronvolt>;
inline constexpr auto daeV = si::deca<electronvolt>; constexpr auto daeV = si::deca<electronvolt>;
inline constexpr auto heV = si::hecto<electronvolt>; constexpr auto heV = si::hecto<electronvolt>;
inline constexpr auto keV = si::kilo<electronvolt>; constexpr auto keV = si::kilo<electronvolt>;
inline constexpr auto MeV = si::mega<electronvolt>; constexpr auto MeV = si::mega<electronvolt>;
inline constexpr auto GeV = si::giga<electronvolt>; constexpr auto GeV = si::giga<electronvolt>;
inline constexpr auto TeV = si::tera<electronvolt>; constexpr auto TeV = si::tera<electronvolt>;
inline constexpr auto PeV = si::peta<electronvolt>; constexpr auto PeV = si::peta<electronvolt>;
inline constexpr auto EeV = si::exa<electronvolt>; constexpr auto EeV = si::exa<electronvolt>;
inline constexpr auto ZeV = si::zetta<electronvolt>; constexpr auto ZeV = si::zetta<electronvolt>;
inline constexpr auto YeV = si::yotta<electronvolt>; constexpr auto YeV = si::yotta<electronvolt>;
inline constexpr auto ReV = si::ronna<electronvolt>; constexpr auto ReV = si::ronna<electronvolt>;
inline constexpr auto QeV = si::quetta<electronvolt>; constexpr auto QeV = si::quetta<electronvolt>;
inline constexpr auto qb = si::quecto<barn>; constexpr auto qb = si::quecto<barn>;
inline constexpr auto rb = si::ronto<barn>; constexpr auto rb = si::ronto<barn>;
inline constexpr auto yb = si::yocto<barn>; constexpr auto yb = si::yocto<barn>;
inline constexpr auto zb = si::zepto<barn>; constexpr auto zb = si::zepto<barn>;
inline constexpr auto ab = si::atto<barn>; constexpr auto ab = si::atto<barn>;
inline constexpr auto fb = si::femto<barn>; constexpr auto fb = si::femto<barn>;
inline constexpr auto pb = si::pico<barn>; constexpr auto pb = si::pico<barn>;
inline constexpr auto nb = si::nano<barn>; constexpr auto nb = si::nano<barn>;
inline constexpr auto ub = si::micro<barn>; constexpr auto ub = si::micro<barn>;
inline constexpr auto mb = si::milli<barn>; constexpr auto mb = si::milli<barn>;
inline constexpr auto b = barn; constexpr auto b = barn;
inline constexpr auto m_e = electron_mass; constexpr auto m_e = electron_mass;
inline constexpr auto m_p = proton_mass; constexpr auto m_p = proton_mass;
inline constexpr auto m_n = neutron_mass; constexpr auto m_n = neutron_mass;
inline constexpr auto c = speed_of_light; constexpr auto c = speed_of_light;
inline constexpr auto c2 = square(speed_of_light); constexpr auto c2 = square(speed_of_light);
} // namespace unit_symbols } // namespace unit_symbols
} // namespace hep } // namespace hep

View File

@@ -39,65 +39,65 @@ namespace mp_units::iau {
// clang-format off // clang-format off
// time // time
inline constexpr struct day final : named_unit<"D", si::day> {} day; constexpr struct day final : named_unit<"D", si::day> {} day;
inline constexpr struct Julian_year final : named_unit<"a", mag_ratio<365'25, 100> * day> {} Julian_year; constexpr struct Julian_year final : named_unit<"a", mag_ratio<365'25, 100> * day> {} Julian_year;
// mass // mass
// https://en.wikipedia.org/wiki/Solar_mass // https://en.wikipedia.org/wiki/Solar_mass
// TODO What is the official mass of sun (every source in the Internet provides a different value) // TODO What is the official mass of sun (every source in the Internet provides a different value)
inline constexpr struct solar_mass final : named_unit<symbol_text{u8"M_☉", "M_SUN"}, mag_ratio<198'847, 100'000> * mag_power<10, 30> * si::kilogram> {} solar_mass; constexpr struct solar_mass final : named_unit<symbol_text{u8"M_☉", "M_SUN"}, mag_ratio<198'847, 100'000> * mag_power<10, 30> * si::kilogram> {} solar_mass;
inline constexpr struct Jupiter_mass final : named_unit<"M_JUP", mag_ratio<1'898, 1'000> * mag_power<10, 27> * si::kilogram> {} Jupiter_mass; constexpr struct Jupiter_mass final : named_unit<"M_JUP", mag_ratio<1'898, 1'000> * mag_power<10, 27> * si::kilogram> {} Jupiter_mass;
inline constexpr struct Earth_mass final : named_unit<"M_EARTH", mag_ratio<59'742, 10'000> * mag_power<10, 24> * si::kilogram> {} Earth_mass; constexpr struct Earth_mass final : named_unit<"M_EARTH", mag_ratio<59'742, 10'000> * mag_power<10, 24> * si::kilogram> {} Earth_mass;
// length // length
inline constexpr auto astronomical_unit = si::astronomical_unit; constexpr auto astronomical_unit = si::astronomical_unit;
// https://en.wikipedia.org/wiki/Lunar_distance_(astronomy) // https://en.wikipedia.org/wiki/Lunar_distance_(astronomy)
inline constexpr struct lunar_distance final : named_unit<"LD", mag<384'399> * si::kilo<si::metre>> {} lunar_distance; constexpr struct lunar_distance final : named_unit<"LD", mag<384'399> * si::kilo<si::metre>> {} lunar_distance;
// https://en.wikipedia.org/wiki/Light-year // https://en.wikipedia.org/wiki/Light-year
inline constexpr struct light_year final : named_unit<"ly", mag<9'460'730'472'580'800> * si::metre> {} light_year; constexpr struct light_year final : named_unit<"ly", mag<9'460'730'472'580'800> * si::metre> {} light_year;
// https://en.wikipedia.org/wiki/Parsec // https://en.wikipedia.org/wiki/Parsec
inline constexpr struct parsec final : named_unit<"pc", astronomical_unit / (mag_ratio<1, 3600> * si::degree)> {} parsec; constexpr struct parsec final : named_unit<"pc", astronomical_unit / (mag_ratio<1, 3600> * si::degree)> {} parsec;
// https://en.wikipedia.org/wiki/Angstrom // https://en.wikipedia.org/wiki/Angstrom
inline constexpr struct angstrom final : named_unit<symbol_text{u8"Å", "A"}, mag_power<10, -10> * si::metre> {} angstrom; constexpr struct angstrom final : named_unit<symbol_text{u8"Å", "A"}, mag_power<10, -10> * si::metre> {} angstrom;
// selected constants // selected constants
// https://en.wikipedia.org/wiki/Astronomical_constant // https://en.wikipedia.org/wiki/Astronomical_constant
inline constexpr struct gaussian_gravitational_constant final : constexpr struct gaussian_gravitational_constant final :
named_unit<"k", mag_ratio<1'720'209'895, 100'000'000'000> * pow<3, 2>(astronomical_unit) / pow<1,2>(solar_mass) / day> {} gaussian_gravitational_constant; named_unit<"k", mag_ratio<1'720'209'895, 100'000'000'000> * pow<3, 2>(astronomical_unit) / pow<1,2>(solar_mass) / day> {} gaussian_gravitational_constant;
inline constexpr struct speed_of_light final : constexpr struct speed_of_light final :
named_unit<symbol_text{u8"c₀", "c_0"}, si::si2019::speed_of_light_in_vacuum> {} speed_of_light; named_unit<symbol_text{u8"c₀", "c_0"}, si::si2019::speed_of_light_in_vacuum> {} speed_of_light;
inline constexpr struct constant_of_gravitation final : constexpr struct constant_of_gravitation final :
named_unit<"G", mag_ratio<667'430, 100'000> * mag_power<10, -11> * cubic(si::metre) / si::kilogram / square(si::second)> {} constant_of_gravitation; named_unit<"G", mag_ratio<667'430, 100'000> * mag_power<10, -11> * cubic(si::metre) / si::kilogram / square(si::second)> {} constant_of_gravitation;
inline constexpr struct hubble_constant final : constexpr struct hubble_constant final :
named_unit<symbol_text{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant; named_unit<symbol_text{u8"H₀", "H_0"}, mag_ratio<701, 10> * si::kilo<si::metre> / si::second / si::mega<parsec>> {} hubble_constant;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto D = day; constexpr auto D = day;
inline constexpr auto a = Julian_year; constexpr auto a = Julian_year;
inline constexpr auto M_SUN = solar_mass; constexpr auto M_SUN = solar_mass;
inline constexpr auto M_JUP = Jupiter_mass; constexpr auto M_JUP = Jupiter_mass;
inline constexpr auto M_EARTH = Earth_mass; constexpr auto M_EARTH = Earth_mass;
inline constexpr auto au = astronomical_unit; constexpr auto au = astronomical_unit;
inline constexpr auto LD = lunar_distance; constexpr auto LD = lunar_distance;
inline constexpr auto ly = light_year; constexpr auto ly = light_year;
inline constexpr auto pc = parsec; constexpr auto pc = parsec;
inline constexpr auto A = angstrom; constexpr auto A = angstrom;
inline constexpr auto k = gaussian_gravitational_constant; constexpr auto k = gaussian_gravitational_constant;
inline constexpr auto c_0 = speed_of_light; constexpr auto c_0 = speed_of_light;
inline constexpr auto G = constant_of_gravitation; constexpr auto G = constant_of_gravitation;
inline constexpr auto H_0 = hubble_constant; constexpr auto H_0 = hubble_constant;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -42,14 +42,14 @@ template<PrefixableUnit U> struct yobi_ final : prefixed_unit<"Yi", mag_power<2,
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
template<PrefixableUnit auto U> inline constexpr kibi_<MP_UNITS_REMOVE_CONST(decltype(U))> kibi; template<PrefixableUnit auto U> constexpr kibi_<MP_UNITS_REMOVE_CONST(decltype(U))> kibi;
template<PrefixableUnit auto U> inline constexpr mebi_<MP_UNITS_REMOVE_CONST(decltype(U))> mebi; template<PrefixableUnit auto U> constexpr mebi_<MP_UNITS_REMOVE_CONST(decltype(U))> mebi;
template<PrefixableUnit auto U> inline constexpr gibi_<MP_UNITS_REMOVE_CONST(decltype(U))> gibi; template<PrefixableUnit auto U> constexpr gibi_<MP_UNITS_REMOVE_CONST(decltype(U))> gibi;
template<PrefixableUnit auto U> inline constexpr tebi_<MP_UNITS_REMOVE_CONST(decltype(U))> tebi; template<PrefixableUnit auto U> constexpr tebi_<MP_UNITS_REMOVE_CONST(decltype(U))> tebi;
template<PrefixableUnit auto U> inline constexpr pebi_<MP_UNITS_REMOVE_CONST(decltype(U))> pebi; template<PrefixableUnit auto U> constexpr pebi_<MP_UNITS_REMOVE_CONST(decltype(U))> pebi;
template<PrefixableUnit auto U> inline constexpr exbi_<MP_UNITS_REMOVE_CONST(decltype(U))> exbi; template<PrefixableUnit auto U> constexpr exbi_<MP_UNITS_REMOVE_CONST(decltype(U))> exbi;
template<PrefixableUnit auto U> inline constexpr zebi_<MP_UNITS_REMOVE_CONST(decltype(U))> zebi; template<PrefixableUnit auto U> constexpr zebi_<MP_UNITS_REMOVE_CONST(decltype(U))> zebi;
template<PrefixableUnit auto U> inline constexpr yobi_<MP_UNITS_REMOVE_CONST(decltype(U))> yobi; template<PrefixableUnit auto U> constexpr yobi_<MP_UNITS_REMOVE_CONST(decltype(U))> yobi;
// clang-format on // clang-format on
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

View File

@@ -36,40 +36,40 @@ namespace mp_units::iec80000 {
// dimensions of base quantities // dimensions of base quantities
// clang-format off // clang-format off
inline constexpr struct dim_traffic_intensity final : base_dimension<"A"> {} dim_traffic_intensity; constexpr struct dim_traffic_intensity final : base_dimension<"A"> {} dim_traffic_intensity;
// clang-format on // clang-format on
// quantities // quantities
QUANTITY_SPEC(traffic_intensity, dim_traffic_intensity); QUANTITY_SPEC(traffic_intensity, dim_traffic_intensity);
QUANTITY_SPEC(traffic_offered_intensity, traffic_intensity); QUANTITY_SPEC(traffic_offered_intensity, traffic_intensity);
QUANTITY_SPEC(traffic_carried_intensity, traffic_intensity); QUANTITY_SPEC(traffic_carried_intensity, traffic_intensity);
inline constexpr auto traffic_load = traffic_carried_intensity; constexpr auto traffic_load = traffic_carried_intensity;
QUANTITY_SPEC(mean_queue_length, dimensionless); QUANTITY_SPEC(mean_queue_length, dimensionless);
QUANTITY_SPEC(loss_probability, dimensionless); QUANTITY_SPEC(loss_probability, dimensionless);
QUANTITY_SPEC(waiting_probability, dimensionless); QUANTITY_SPEC(waiting_probability, dimensionless);
QUANTITY_SPEC(call_intensity, inverse(isq::duration)); QUANTITY_SPEC(call_intensity, inverse(isq::duration));
inline constexpr auto calling_rate = call_intensity; constexpr auto calling_rate = call_intensity;
QUANTITY_SPEC(completed_call_intensity, call_intensity); QUANTITY_SPEC(completed_call_intensity, call_intensity);
QUANTITY_SPEC(storage_capacity, dimensionless, is_kind); QUANTITY_SPEC(storage_capacity, dimensionless, is_kind);
inline constexpr auto storage_size = storage_capacity; constexpr auto storage_size = storage_capacity;
QUANTITY_SPEC(equivalent_binary_storage_capacity, storage_capacity); QUANTITY_SPEC(equivalent_binary_storage_capacity, storage_capacity);
QUANTITY_SPEC(transfer_rate, storage_capacity / isq::duration); QUANTITY_SPEC(transfer_rate, storage_capacity / isq::duration);
QUANTITY_SPEC(period_of_data_elements, isq::period, inverse(transfer_rate)); QUANTITY_SPEC(period_of_data_elements, isq::period, inverse(transfer_rate));
QUANTITY_SPEC(binary_digit_rate, transfer_rate); QUANTITY_SPEC(binary_digit_rate, transfer_rate);
inline constexpr auto bit_rate = binary_digit_rate; constexpr auto bit_rate = binary_digit_rate;
QUANTITY_SPEC(period_of_binary_digits, isq::period, inverse(binary_digit_rate)); QUANTITY_SPEC(period_of_binary_digits, isq::period, inverse(binary_digit_rate));
inline constexpr auto bit_period = period_of_binary_digits; constexpr auto bit_period = period_of_binary_digits;
QUANTITY_SPEC(equivalent_binary_digit_rate, binary_digit_rate); QUANTITY_SPEC(equivalent_binary_digit_rate, binary_digit_rate);
inline constexpr auto equivalent_bit_rate = bit_rate; constexpr auto equivalent_bit_rate = bit_rate;
QUANTITY_SPEC(modulation_rate, inverse(isq::duration)); QUANTITY_SPEC(modulation_rate, inverse(isq::duration));
inline constexpr auto line_digit_rate = modulation_rate; constexpr auto line_digit_rate = modulation_rate;
QUANTITY_SPEC(quantizing_distortion_power, isq::power); QUANTITY_SPEC(quantizing_distortion_power, isq::power);
QUANTITY_SPEC(carrier_power, isq::power); QUANTITY_SPEC(carrier_power, isq::power);
QUANTITY_SPEC(signal_energy_per_binary_digit, carrier_power* period_of_binary_digits); QUANTITY_SPEC(signal_energy_per_binary_digit, carrier_power* period_of_binary_digits);
QUANTITY_SPEC(error_probability, dimensionless); QUANTITY_SPEC(error_probability, dimensionless);
QUANTITY_SPEC(Hamming_distance, dimensionless); QUANTITY_SPEC(Hamming_distance, dimensionless);
QUANTITY_SPEC(clock_frequency, isq::frequency); QUANTITY_SPEC(clock_frequency, isq::frequency);
inline constexpr auto clock_rate = clock_frequency; constexpr auto clock_rate = clock_frequency;
QUANTITY_SPEC(decision_content, dimensionless); QUANTITY_SPEC(decision_content, dimensionless);
// TODO how to model information_content and the following quantities??? // TODO how to model information_content and the following quantities???

View File

@@ -31,81 +31,81 @@ MP_UNITS_EXPORT
namespace mp_units::iec80000::unit_symbols { namespace mp_units::iec80000::unit_symbols {
// bit // bit
inline constexpr auto kbit = si::kilo<bit>; constexpr auto kbit = si::kilo<bit>;
inline constexpr auto Mbit = si::mega<bit>; constexpr auto Mbit = si::mega<bit>;
inline constexpr auto Gbit = si::giga<bit>; constexpr auto Gbit = si::giga<bit>;
inline constexpr auto Tbit = si::tera<bit>; constexpr auto Tbit = si::tera<bit>;
inline constexpr auto Pbit = si::peta<bit>; constexpr auto Pbit = si::peta<bit>;
inline constexpr auto Ebit = si::exa<bit>; constexpr auto Ebit = si::exa<bit>;
inline constexpr auto Zbit = si::zetta<bit>; constexpr auto Zbit = si::zetta<bit>;
inline constexpr auto Ybit = si::yotta<bit>; constexpr auto Ybit = si::yotta<bit>;
inline constexpr auto Rbit = si::ronna<bit>; constexpr auto Rbit = si::ronna<bit>;
inline constexpr auto Qbit = si::quetta<bit>; constexpr auto Qbit = si::quetta<bit>;
inline constexpr auto Kibit = kibi<bit>; constexpr auto Kibit = kibi<bit>;
inline constexpr auto Mibit = mebi<bit>; constexpr auto Mibit = mebi<bit>;
inline constexpr auto Gibit = gibi<bit>; constexpr auto Gibit = gibi<bit>;
inline constexpr auto Tibit = tebi<bit>; constexpr auto Tibit = tebi<bit>;
inline constexpr auto Pibit = pebi<bit>; constexpr auto Pibit = pebi<bit>;
inline constexpr auto Eibit = exbi<bit>; constexpr auto Eibit = exbi<bit>;
// octet // octet
inline constexpr auto o = octet; constexpr auto o = octet;
inline constexpr auto ko = si::kilo<octet>; constexpr auto ko = si::kilo<octet>;
inline constexpr auto Mo = si::mega<octet>; constexpr auto Mo = si::mega<octet>;
inline constexpr auto Go = si::giga<octet>; constexpr auto Go = si::giga<octet>;
inline constexpr auto To = si::tera<octet>; constexpr auto To = si::tera<octet>;
inline constexpr auto Po = si::peta<octet>; constexpr auto Po = si::peta<octet>;
inline constexpr auto Eo = si::exa<octet>; constexpr auto Eo = si::exa<octet>;
inline constexpr auto Zo = si::zetta<octet>; constexpr auto Zo = si::zetta<octet>;
inline constexpr auto Yo = si::yotta<octet>; constexpr auto Yo = si::yotta<octet>;
inline constexpr auto Ro = si::ronna<octet>; constexpr auto Ro = si::ronna<octet>;
inline constexpr auto Qo = si::quetta<octet>; constexpr auto Qo = si::quetta<octet>;
inline constexpr auto Kio = kibi<octet>; constexpr auto Kio = kibi<octet>;
inline constexpr auto Mio = mebi<octet>; constexpr auto Mio = mebi<octet>;
inline constexpr auto Gio = gibi<octet>; constexpr auto Gio = gibi<octet>;
inline constexpr auto Tio = tebi<octet>; constexpr auto Tio = tebi<octet>;
inline constexpr auto Pio = pebi<octet>; constexpr auto Pio = pebi<octet>;
inline constexpr auto Eio = exbi<octet>; constexpr auto Eio = exbi<octet>;
// byte // byte
inline constexpr auto B = byte; constexpr auto B = byte;
inline constexpr auto kB = si::kilo<byte>; constexpr auto kB = si::kilo<byte>;
inline constexpr auto MB = si::mega<byte>; constexpr auto MB = si::mega<byte>;
inline constexpr auto GB = si::giga<byte>; constexpr auto GB = si::giga<byte>;
inline constexpr auto TB = si::tera<byte>; constexpr auto TB = si::tera<byte>;
inline constexpr auto PB = si::peta<byte>; constexpr auto PB = si::peta<byte>;
inline constexpr auto EB = si::exa<byte>; constexpr auto EB = si::exa<byte>;
inline constexpr auto ZB = si::zetta<byte>; constexpr auto ZB = si::zetta<byte>;
inline constexpr auto YB = si::yotta<byte>; constexpr auto YB = si::yotta<byte>;
inline constexpr auto RB = si::ronna<byte>; constexpr auto RB = si::ronna<byte>;
inline constexpr auto QB = si::quetta<byte>; constexpr auto QB = si::quetta<byte>;
inline constexpr auto KiB = kibi<byte>; constexpr auto KiB = kibi<byte>;
inline constexpr auto MiB = mebi<byte>; constexpr auto MiB = mebi<byte>;
inline constexpr auto GiB = gibi<byte>; constexpr auto GiB = gibi<byte>;
inline constexpr auto TiB = tebi<byte>; constexpr auto TiB = tebi<byte>;
inline constexpr auto PiB = pebi<byte>; constexpr auto PiB = pebi<byte>;
inline constexpr auto EiB = exbi<byte>; constexpr auto EiB = exbi<byte>;
// baud // baud
inline constexpr auto Bd = baud; constexpr auto Bd = baud;
inline constexpr auto kBd = si::kilo<baud>; constexpr auto kBd = si::kilo<baud>;
inline constexpr auto MBd = si::mega<baud>; constexpr auto MBd = si::mega<baud>;
inline constexpr auto GBd = si::giga<baud>; constexpr auto GBd = si::giga<baud>;
inline constexpr auto TBd = si::tera<baud>; constexpr auto TBd = si::tera<baud>;
inline constexpr auto PBd = si::peta<baud>; constexpr auto PBd = si::peta<baud>;
inline constexpr auto EBd = si::exa<baud>; constexpr auto EBd = si::exa<baud>;
inline constexpr auto ZBd = si::zetta<baud>; constexpr auto ZBd = si::zetta<baud>;
inline constexpr auto YBd = si::yotta<baud>; constexpr auto YBd = si::yotta<baud>;
inline constexpr auto RBd = si::ronna<baud>; constexpr auto RBd = si::ronna<baud>;
inline constexpr auto QBd = si::quetta<baud>; constexpr auto QBd = si::quetta<baud>;
// erlang // erlang
// TODO do we need prefixed versions of Erlang? // TODO do we need prefixed versions of Erlang?
inline constexpr auto E = erlang; constexpr auto E = erlang;
} // namespace mp_units::iec80000::unit_symbols } // namespace mp_units::iec80000::unit_symbols

View File

@@ -34,11 +34,11 @@ MP_UNITS_EXPORT
namespace mp_units::iec80000 { namespace mp_units::iec80000 {
// clang-format off // clang-format off
inline constexpr struct erlang final : named_unit<"E", kind_of<traffic_intensity>> {} erlang; constexpr struct erlang final : named_unit<"E", kind_of<traffic_intensity>> {} erlang;
inline constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit; constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
inline constexpr struct octet final : named_unit<"o", mag<8> * bit> {} octet; constexpr struct octet final : named_unit<"o", mag<8> * bit> {} octet;
inline constexpr struct byte final : named_unit<"B", mag<8> * bit> {} byte; constexpr struct byte final : named_unit<"B", mag<8> * bit> {} byte;
inline constexpr struct baud final : named_unit<"Bd", one / si::second, kind_of<modulation_rate>> {} baud; constexpr struct baud final : named_unit<"Bd", one / si::second, kind_of<modulation_rate>> {} baud;
// clang-format on // clang-format on
} // namespace mp_units::iec80000 } // namespace mp_units::iec80000

View File

@@ -39,67 +39,67 @@ using namespace international;
// clang-format off // clang-format off
// https://en.wikipedia.org/wiki/Imperial_units#Length // https://en.wikipedia.org/wiki/Imperial_units#Length
inline constexpr struct hand final : named_unit<"hh", mag_ratio<1, 3> * foot> {} hand; constexpr struct hand final : named_unit<"hh", mag_ratio<1, 3> * foot> {} hand;
inline constexpr struct barleycorn final : named_unit<"Bc", mag_ratio<1, 3> * inch> {} barleycorn; constexpr struct barleycorn final : named_unit<"Bc", mag_ratio<1, 3> * inch> {} barleycorn;
inline constexpr struct thou final : named_unit<"th", mag_ratio<1, 12'000> * foot> {} thou; constexpr struct thou final : named_unit<"th", mag_ratio<1, 12'000> * foot> {} thou;
inline constexpr struct chain final : named_unit<"ch", mag<22> * yard> {} chain; constexpr struct chain final : named_unit<"ch", mag<22> * yard> {} chain;
inline constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong; constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
// maritime units // maritime units
inline constexpr struct cable final : named_unit<"cb", mag_ratio<1, 10> * nautical_mile> {} cable; constexpr struct cable final : named_unit<"cb", mag_ratio<1, 10> * nautical_mile> {} cable;
inline constexpr struct fathom final : named_unit<"ftm", mag_ratio<1, 1000> * nautical_mile> {} fathom; constexpr struct fathom final : named_unit<"ftm", mag_ratio<1, 1000> * nautical_mile> {} fathom;
// survey // survey
inline constexpr struct link final : named_unit<"li", mag_ratio<1, 100> * chain> {} link; constexpr struct link final : named_unit<"li", mag_ratio<1, 100> * chain> {} link;
inline constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod; constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
// https://en.wikipedia.org/wiki/Imperial_units#Area // https://en.wikipedia.org/wiki/Imperial_units#Area
inline constexpr struct perch final : named_unit<"perch", square(rod)> {} perch; constexpr struct perch final : named_unit<"perch", square(rod)> {} perch;
inline constexpr struct rood final : named_unit<"rood", mag<40> * perch> {} rood; constexpr struct rood final : named_unit<"rood", mag<40> * perch> {} rood;
inline constexpr struct acre final : named_unit<"acre", mag<4> * rood> {} acre; constexpr struct acre final : named_unit<"acre", mag<4> * rood> {} acre;
// https://en.wikipedia.org/wiki/Imperial_units#Volume // https://en.wikipedia.org/wiki/Imperial_units#Volume
inline constexpr struct gallon final : named_unit<"gal", mag_ratio<454'609, 100'000> * si::litre> {} gallon; constexpr struct gallon final : named_unit<"gal", mag_ratio<454'609, 100'000> * si::litre> {} gallon;
inline constexpr struct quart final : named_unit<"qt", mag_ratio<1, 4> * gallon> {} quart; constexpr struct quart final : named_unit<"qt", mag_ratio<1, 4> * gallon> {} quart;
inline constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint; constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint;
inline constexpr struct gill final : named_unit<"gi", mag_ratio<1, 4> * pint> {} gill; constexpr struct gill final : named_unit<"gi", mag_ratio<1, 4> * pint> {} gill;
inline constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 5> * gill> {} fluid_ounce; constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 5> * gill> {} fluid_ounce;
// https://en.wikipedia.org/wiki/Avoirdupois_system#Post-Elizabethan_units // https://en.wikipedia.org/wiki/Avoirdupois_system#Post-Elizabethan_units
inline constexpr auto drachm = dram; constexpr auto drachm = dram;
inline constexpr struct stone final : named_unit<"st", mag<14> * pound> {} stone; constexpr struct stone final : named_unit<"st", mag<14> * pound> {} stone;
inline constexpr struct quarter final : named_unit<"qr", mag<2> * stone> {} quarter; constexpr struct quarter final : named_unit<"qr", mag<2> * stone> {} quarter;
inline constexpr struct long_hundredweight final : named_unit<"cwt", mag<8> * stone> {} long_hundredweight; constexpr struct long_hundredweight final : named_unit<"cwt", mag<8> * stone> {} long_hundredweight;
inline constexpr struct ton final : named_unit<"t", mag<2'240> * pound> {} ton; constexpr struct ton final : named_unit<"t", mag<2'240> * pound> {} ton;
inline constexpr auto long_ton = ton; constexpr auto long_ton = ton;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
using namespace international::unit_symbols; using namespace international::unit_symbols;
inline constexpr auto hh = hand; constexpr auto hh = hand;
inline constexpr auto Bc = barleycorn; constexpr auto Bc = barleycorn;
inline constexpr auto th = thou; constexpr auto th = thou;
inline constexpr auto ch = chain; constexpr auto ch = chain;
inline constexpr auto fur = furlong; constexpr auto fur = furlong;
inline constexpr auto cb = cable; constexpr auto cb = cable;
inline constexpr auto ftm = fathom; constexpr auto ftm = fathom;
inline constexpr auto li = link; constexpr auto li = link;
inline constexpr auto rd = rod; constexpr auto rd = rod;
inline constexpr auto gal = gallon; constexpr auto gal = gallon;
inline constexpr auto qt = quart; constexpr auto qt = quart;
inline constexpr auto pt = pint; constexpr auto pt = pint;
inline constexpr auto gi = gill; constexpr auto gi = gill;
inline constexpr auto fl_oz = fluid_ounce; constexpr auto fl_oz = fluid_ounce;
inline constexpr auto st = stone; constexpr auto st = stone;
inline constexpr auto qr = quarter; constexpr auto qr = quarter;
inline constexpr auto cwt = long_hundredweight; constexpr auto cwt = long_hundredweight;
inline constexpr auto t = ton; constexpr auto t = ton;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -37,72 +37,72 @@ namespace mp_units::international {
// clang-format off // clang-format off
// mass // mass
inline constexpr struct pound final : named_unit<"lb", mag_ratio<45'359'237, 100'000'000> * si::kilogram> {} pound; constexpr struct pound final : named_unit<"lb", mag_ratio<45'359'237, 100'000'000> * si::kilogram> {} pound;
inline constexpr struct ounce final : named_unit<"oz", mag_ratio<1, 16> * pound> {} ounce; constexpr struct ounce final : named_unit<"oz", mag_ratio<1, 16> * pound> {} ounce;
inline constexpr struct dram final : named_unit<"dr", mag_ratio<1, 16> * ounce> {} dram; constexpr struct dram final : named_unit<"dr", mag_ratio<1, 16> * ounce> {} dram;
inline constexpr struct grain final : named_unit<"gr", mag_ratio<1, 7'000> * pound> {} grain; constexpr struct grain final : named_unit<"gr", mag_ratio<1, 7'000> * pound> {} grain;
// length // length
// https://en.wikipedia.org/wiki/United_States_customary_units#Length // https://en.wikipedia.org/wiki/United_States_customary_units#Length
inline constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard; constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
inline constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot; constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot;
inline constexpr struct inch final : named_unit<"in", mag_ratio<1, 12> * foot> {} inch; constexpr struct inch final : named_unit<"in", mag_ratio<1, 12> * foot> {} inch;
inline constexpr struct pica final : named_unit<"P", mag_ratio<1, 6> * inch> {} pica; constexpr struct pica final : named_unit<"P", mag_ratio<1, 6> * inch> {} pica;
inline constexpr struct point final : named_unit<"p", mag_ratio<1, 12> * pica> {} point; constexpr struct point final : named_unit<"p", mag_ratio<1, 12> * pica> {} point;
inline constexpr struct mil final : named_unit<"mil", mag_ratio<1, 1'000> * inch> {} mil; constexpr struct mil final : named_unit<"mil", mag_ratio<1, 1'000> * inch> {} mil;
inline constexpr struct twip final : named_unit<"twip", mag_ratio<1, 20> * point> {} twip; constexpr struct twip final : named_unit<"twip", mag_ratio<1, 20> * point> {} twip;
inline constexpr struct mile final : named_unit<"mi", mag<1760> * yard> {} mile; constexpr struct mile final : named_unit<"mi", mag<1760> * yard> {} mile;
inline constexpr struct league final : named_unit<"le", mag<3> * mile> {} league; constexpr struct league final : named_unit<"le", mag<3> * mile> {} league;
inline constexpr struct nautical_mile final : named_unit<"nmi", mag<1852> * si::metre> {} nautical_mile; constexpr struct nautical_mile final : named_unit<"nmi", mag<1852> * si::metre> {} nautical_mile;
// speed // speed
inline constexpr struct knot final : named_unit<"kn", nautical_mile / si::hour> {} knot; constexpr struct knot final : named_unit<"kn", nautical_mile / si::hour> {} knot;
// force // force
// https://en.wikipedia.org/wiki/Poundal // https://en.wikipedia.org/wiki/Poundal
inline constexpr struct poundal final : named_unit<"pdl", pound * foot / square(si::second)> {} poundal; constexpr struct poundal final : named_unit<"pdl", pound * foot / square(si::second)> {} poundal;
// https://en.wikipedia.org/wiki/Pound_(force) // https://en.wikipedia.org/wiki/Pound_(force)
inline constexpr struct pound_force final : named_unit<"lbf", pound * si::standard_gravity> {} pound_force; constexpr struct pound_force final : named_unit<"lbf", pound * si::standard_gravity> {} pound_force;
// https://en.wikipedia.org/wiki/Kip_(unit), // https://en.wikipedia.org/wiki/Kip_(unit),
inline constexpr auto kip = si::kilo<pound_force>; constexpr auto kip = si::kilo<pound_force>;
// pressure // pressure
inline constexpr struct psi final : named_unit<"psi", pound_force / square(inch)> {} psi; constexpr struct psi final : named_unit<"psi", pound_force / square(inch)> {} psi;
// power // power
// https://en.wikipedia.org/wiki/Horsepower#Definitions // https://en.wikipedia.org/wiki/Horsepower#Definitions
inline constexpr struct mechanical_horsepower final : named_unit<"hp(I)", mag<33'000> * foot * pound_force / si::minute> {} mechanical_horsepower; constexpr struct mechanical_horsepower final : named_unit<"hp(I)", mag<33'000> * foot * pound_force / si::minute> {} mechanical_horsepower;
// clang-format on // clang-format on
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto lb = pound; constexpr auto lb = pound;
inline constexpr auto oz = ounce; constexpr auto oz = ounce;
inline constexpr auto dr = dram; constexpr auto dr = dram;
inline constexpr auto gr = grain; constexpr auto gr = grain;
inline constexpr auto yd = yard; constexpr auto yd = yard;
inline constexpr auto ft = foot; constexpr auto ft = foot;
inline constexpr auto in = inch; constexpr auto in = inch;
inline constexpr auto P = pica; constexpr auto P = pica;
inline constexpr auto p = point; constexpr auto p = point;
inline constexpr auto mi = mile; constexpr auto mi = mile;
inline constexpr auto le = league; constexpr auto le = league;
inline constexpr auto nmi = nautical_mile; constexpr auto nmi = nautical_mile;
inline constexpr auto kn = knot; constexpr auto kn = knot;
inline constexpr auto kt = knot; constexpr auto kt = knot;
inline constexpr auto mph = mile / si::hour; constexpr auto mph = mile / si::hour;
inline constexpr auto pdl = poundal; constexpr auto pdl = poundal;
inline constexpr auto lbf = pound_force; constexpr auto lbf = pound_force;
inline constexpr auto hp = mechanical_horsepower; constexpr auto hp = mechanical_horsepower;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -35,20 +35,20 @@ namespace mp_units::isq {
// clang-format off // clang-format off
// dimensions of base quantities // dimensions of base quantities
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length; constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass; constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time; constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
inline constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current; constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current;
inline constexpr struct dim_thermodynamic_temperature final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature; constexpr struct dim_thermodynamic_temperature final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
inline constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance; constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance;
inline constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity; constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity;
// clang-format on // clang-format on
// base quantities // base quantities
QUANTITY_SPEC(length, dim_length); QUANTITY_SPEC(length, dim_length);
QUANTITY_SPEC(mass, dim_mass); QUANTITY_SPEC(mass, dim_mass);
QUANTITY_SPEC(time, dim_time); QUANTITY_SPEC(time, dim_time);
inline constexpr auto duration = time; constexpr auto duration = time;
QUANTITY_SPEC(electric_current, dim_electric_current); QUANTITY_SPEC(electric_current, dim_electric_current);
QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature); QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature);
QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance); QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance);

View File

@@ -39,25 +39,25 @@ namespace mp_units::isq {
QUANTITY_SPEC(electric_charge, electric_current* time); QUANTITY_SPEC(electric_charge, electric_current* time);
QUANTITY_SPEC(electric_charge_density, electric_charge / volume); QUANTITY_SPEC(electric_charge_density, electric_charge / volume);
inline constexpr auto volume_electric_charge = electric_charge_density; constexpr auto volume_electric_charge = electric_charge_density;
QUANTITY_SPEC(surface_density_of_electric_charge, electric_charge / area); QUANTITY_SPEC(surface_density_of_electric_charge, electric_charge / area);
inline constexpr auto areic_electric_charge = surface_density_of_electric_charge; constexpr auto areic_electric_charge = surface_density_of_electric_charge;
QUANTITY_SPEC(linear_density_of_electric_charge, electric_charge / length); QUANTITY_SPEC(linear_density_of_electric_charge, electric_charge / length);
inline constexpr auto lineic_electric_charge = linear_density_of_electric_charge; constexpr auto lineic_electric_charge = linear_density_of_electric_charge;
QUANTITY_SPEC(electric_dipole_moment, electric_charge* position_vector); // vector QUANTITY_SPEC(electric_dipole_moment, electric_charge* position_vector); // vector
QUANTITY_SPEC(electric_polarization, electric_dipole_moment / volume); // vector QUANTITY_SPEC(electric_polarization, electric_dipole_moment / volume); // vector
QUANTITY_SPEC(electric_current_density, electric_charge_density* velocity); // vector QUANTITY_SPEC(electric_current_density, electric_charge_density* velocity); // vector
inline constexpr auto areic_electric_current = electric_current_density; constexpr auto areic_electric_current = electric_current_density;
QUANTITY_SPEC(linear_electric_current_density, surface_density_of_electric_charge* velocity); // vector QUANTITY_SPEC(linear_electric_current_density, surface_density_of_electric_charge* velocity); // vector
inline constexpr auto lineic_electric_current = linear_electric_current_density; constexpr auto lineic_electric_current = linear_electric_current_density;
QUANTITY_SPEC(electric_field_strength, force / electric_charge); // vector QUANTITY_SPEC(electric_field_strength, force / electric_charge); // vector
QUANTITY_SPEC(electric_potential, electric_field_strength* length, QUANTITY_SPEC(electric_potential, electric_field_strength* length,
quantity_character::scalar); // TODO what is a correct equation here? quantity_character::scalar); // TODO what is a correct equation here?
QUANTITY_SPEC(electric_potential_difference, electric_potential, quantity_character::scalar); QUANTITY_SPEC(electric_potential_difference, electric_potential, quantity_character::scalar);
QUANTITY_SPEC(voltage, electric_potential); QUANTITY_SPEC(voltage, electric_potential);
inline constexpr auto electric_tension = voltage; constexpr auto electric_tension = voltage;
QUANTITY_SPEC(electric_flux_density, electric_polarization); // vector QUANTITY_SPEC(electric_flux_density, electric_polarization); // vector
inline constexpr auto electric_displacement = electric_flux_density; constexpr auto electric_displacement = electric_flux_density;
QUANTITY_SPEC(capacitance, electric_charge / voltage); QUANTITY_SPEC(capacitance, electric_charge / voltage);
// TODO how to calculate an argument of a vector product? // TODO how to calculate an argument of a vector product?
QUANTITY_SPEC(magnetic_flux_density, force / (electric_charge * velocity), quantity_character::vector); QUANTITY_SPEC(magnetic_flux_density, force / (electric_charge * velocity), quantity_character::vector);
@@ -66,13 +66,13 @@ QUANTITY_SPEC(magnetic_vector_potential,
QUANTITY_SPEC(linked_flux, magnetic_vector_potential* displacement, quantity_character::scalar); QUANTITY_SPEC(linked_flux, magnetic_vector_potential* displacement, quantity_character::scalar);
QUANTITY_SPEC(magnetic_constant, QUANTITY_SPEC(magnetic_constant,
electric_potential* time / (electric_current * length)); // TODO what is a correct equation here? electric_potential* time / (electric_current * length)); // TODO what is a correct equation here?
inline constexpr auto permeability_of_vacuum = magnetic_constant; constexpr auto permeability_of_vacuum = magnetic_constant;
QUANTITY_SPEC(phase_speed_of_electromagnetic_waves, angular_frequency / angular_wavenumber); QUANTITY_SPEC(phase_speed_of_electromagnetic_waves, angular_frequency / angular_wavenumber);
QUANTITY_SPEC(speed_of_light_in_vacuum, speed); QUANTITY_SPEC(speed_of_light_in_vacuum, speed);
inline constexpr auto light_speed_in_vacuum = speed_of_light_in_vacuum; constexpr auto light_speed_in_vacuum = speed_of_light_in_vacuum;
inline constexpr auto luminal_speed = speed_of_light_in_vacuum; constexpr auto luminal_speed = speed_of_light_in_vacuum;
QUANTITY_SPEC(electric_constant, inverse(magnetic_constant* pow<2>(speed_of_light_in_vacuum))); QUANTITY_SPEC(electric_constant, inverse(magnetic_constant* pow<2>(speed_of_light_in_vacuum)));
inline constexpr auto permittivity_of_vacuum = electric_constant; constexpr auto permittivity_of_vacuum = electric_constant;
QUANTITY_SPEC(permittivity, electric_flux_density / electric_field_strength, quantity_character::scalar); QUANTITY_SPEC(permittivity, electric_flux_density / electric_field_strength, quantity_character::scalar);
QUANTITY_SPEC(relative_permittivity, dimensionless, permittivity / electric_constant); QUANTITY_SPEC(relative_permittivity, dimensionless, permittivity / electric_constant);
QUANTITY_SPEC(electric_susceptibility, dimensionless, QUANTITY_SPEC(electric_susceptibility, dimensionless,
@@ -84,10 +84,10 @@ QUANTITY_SPEC(total_current, electric_current);
QUANTITY_SPEC(total_current_density, electric_current_density); // vector QUANTITY_SPEC(total_current_density, electric_current_density); // vector
QUANTITY_SPEC(magnetic_flux, magnetic_flux_density* area, quantity_character::scalar); QUANTITY_SPEC(magnetic_flux, magnetic_flux_density* area, quantity_character::scalar);
QUANTITY_SPEC(magnetic_moment, electric_current* area, quantity_character::vector); QUANTITY_SPEC(magnetic_moment, electric_current* area, quantity_character::vector);
inline constexpr auto magnetic_area_moment = magnetic_moment; constexpr auto magnetic_area_moment = magnetic_moment;
QUANTITY_SPEC(magnetization, magnetic_moment / volume); // vector QUANTITY_SPEC(magnetization, magnetic_moment / volume); // vector
QUANTITY_SPEC(magnetic_field_strength, magnetization); // vector QUANTITY_SPEC(magnetic_field_strength, magnetization); // vector
inline constexpr auto magnetizing_field = magnetic_field_strength; constexpr auto magnetizing_field = magnetic_field_strength;
QUANTITY_SPEC(permeability, magnetic_flux_density / magnetic_field_strength, quantity_character::scalar); QUANTITY_SPEC(permeability, magnetic_flux_density / magnetic_field_strength, quantity_character::scalar);
QUANTITY_SPEC(relative_permeability, dimensionless, permeability / magnetic_constant); QUANTITY_SPEC(relative_permeability, dimensionless, permeability / magnetic_constant);
QUANTITY_SPEC(magnetic_susceptibility, dimensionless, magnetization / magnetic_field_strength, QUANTITY_SPEC(magnetic_susceptibility, dimensionless, magnetization / magnetic_field_strength,
@@ -97,10 +97,10 @@ QUANTITY_SPEC(magnetic_dipole_moment, magnetic_constant* magnetic_moment); // v
QUANTITY_SPEC(coercivity, magnetic_field_strength, quantity_character::scalar); QUANTITY_SPEC(coercivity, magnetic_field_strength, quantity_character::scalar);
QUANTITY_SPEC(electromagnetic_energy_density, electric_field_strength* electric_flux_density, QUANTITY_SPEC(electromagnetic_energy_density, electric_field_strength* electric_flux_density,
quantity_character::scalar); quantity_character::scalar);
inline constexpr auto volumic_electromagnetic_energy = electromagnetic_energy_density; constexpr auto volumic_electromagnetic_energy = electromagnetic_energy_density;
QUANTITY_SPEC(Poynting_vector, electric_field_strength* magnetic_field_strength); // vector QUANTITY_SPEC(Poynting_vector, electric_field_strength* magnetic_field_strength); // vector
QUANTITY_SPEC(source_voltage, voltage); QUANTITY_SPEC(source_voltage, voltage);
inline constexpr auto source_tension = source_voltage; constexpr auto source_tension = source_voltage;
QUANTITY_SPEC(scalar_magnetic_potential, electric_current, magnetic_field_strength* length, QUANTITY_SPEC(scalar_magnetic_potential, electric_current, magnetic_field_strength* length,
quantity_character::scalar); // TODO what is a correct equation here? quantity_character::scalar); // TODO what is a correct equation here?
QUANTITY_SPEC(magnetic_tension, electric_current, magnetic_field_strength* position_vector, quantity_character::scalar); QUANTITY_SPEC(magnetic_tension, electric_current, magnetic_field_strength* position_vector, quantity_character::scalar);
@@ -111,26 +111,26 @@ QUANTITY_SPEC(number_of_turns_in_a_winding, dimensionless);
QUANTITY_SPEC(reluctance, magnetic_tension / magnetic_flux); QUANTITY_SPEC(reluctance, magnetic_tension / magnetic_flux);
QUANTITY_SPEC(permeance, inverse(reluctance)); QUANTITY_SPEC(permeance, inverse(reluctance));
QUANTITY_SPEC(inductance, linked_flux / electric_current); QUANTITY_SPEC(inductance, linked_flux / electric_current);
inline constexpr auto self_inductance = inductance; constexpr auto self_inductance = inductance;
QUANTITY_SPEC(mutual_inductance, linked_flux / electric_current); QUANTITY_SPEC(mutual_inductance, linked_flux / electric_current);
QUANTITY_SPEC(coupling_factor, dimensionless, mutual_inductance / pow<1, 2>(pow<2>(self_inductance))); QUANTITY_SPEC(coupling_factor, dimensionless, mutual_inductance / pow<1, 2>(pow<2>(self_inductance)));
QUANTITY_SPEC(leakage_factor, dimensionless, pow<2>(coupling_factor)); QUANTITY_SPEC(leakage_factor, dimensionless, pow<2>(coupling_factor));
QUANTITY_SPEC(conductivity, electric_current_density / electric_field_strength, quantity_character::scalar); QUANTITY_SPEC(conductivity, electric_current_density / electric_field_strength, quantity_character::scalar);
QUANTITY_SPEC(resistivity, inverse(conductivity)); QUANTITY_SPEC(resistivity, inverse(conductivity));
QUANTITY_SPEC(electromagnetism_power, power, voltage* electric_current); QUANTITY_SPEC(electromagnetism_power, power, voltage* electric_current);
inline constexpr auto instantaneous_power = electromagnetism_power; constexpr auto instantaneous_power = electromagnetism_power;
QUANTITY_SPEC(resistance, voltage / electric_current); QUANTITY_SPEC(resistance, voltage / electric_current);
QUANTITY_SPEC(conductance, inverse(resistance)); QUANTITY_SPEC(conductance, inverse(resistance));
QUANTITY_SPEC(phase_difference, phase_angle); QUANTITY_SPEC(phase_difference, phase_angle);
QUANTITY_SPEC(electric_current_phasor, electric_current); QUANTITY_SPEC(electric_current_phasor, electric_current);
QUANTITY_SPEC(voltage_phasor, voltage); QUANTITY_SPEC(voltage_phasor, voltage);
QUANTITY_SPEC(impedance, voltage_phasor / electric_current_phasor); QUANTITY_SPEC(impedance, voltage_phasor / electric_current_phasor);
inline constexpr auto complex_impedance = impedance; constexpr auto complex_impedance = impedance;
QUANTITY_SPEC(resistance_to_alternating_current, impedance); QUANTITY_SPEC(resistance_to_alternating_current, impedance);
QUANTITY_SPEC(reactance, impedance); QUANTITY_SPEC(reactance, impedance);
QUANTITY_SPEC(modulus_of_impedance, impedance); QUANTITY_SPEC(modulus_of_impedance, impedance);
QUANTITY_SPEC(admittance, inverse(impedance)); QUANTITY_SPEC(admittance, inverse(impedance));
inline constexpr auto complex_admittance = admittance; constexpr auto complex_admittance = admittance;
QUANTITY_SPEC(conductance_for_alternating_current, admittance); QUANTITY_SPEC(conductance_for_alternating_current, admittance);
QUANTITY_SPEC(susceptance, admittance); QUANTITY_SPEC(susceptance, admittance);
QUANTITY_SPEC(modulus_of_admittance, admittance); QUANTITY_SPEC(modulus_of_admittance, admittance);

View File

@@ -45,9 +45,9 @@ QUANTITY_SPEC(radiant_energy_density, radiant_energy / volume);
QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavelength, radiant_energy_density / wavelength); QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavelength, radiant_energy_density / wavelength);
QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavenumber, radiant_energy_density / wavenumber); QUANTITY_SPEC(spectral_radiant_energy_density_in_terms_of_wavenumber, radiant_energy_density / wavenumber);
QUANTITY_SPEC(radiant_flux, power, radiant_energy / time); QUANTITY_SPEC(radiant_flux, power, radiant_energy / time);
inline constexpr auto radiant_power = radiant_flux; constexpr auto radiant_power = radiant_flux;
QUANTITY_SPEC(spectral_radiant_flux, radiant_flux / wavelength); QUANTITY_SPEC(spectral_radiant_flux, radiant_flux / wavelength);
inline constexpr auto spectral_radiant_power = spectral_radiant_flux; constexpr auto spectral_radiant_power = spectral_radiant_flux;
QUANTITY_SPEC(radiant_intensity, radiant_flux / solid_angular_measure); QUANTITY_SPEC(radiant_intensity, radiant_flux / solid_angular_measure);
QUANTITY_SPEC(spectral_radiant_intensity, radiant_intensity / wavelength); QUANTITY_SPEC(spectral_radiant_intensity, radiant_intensity / wavelength);
QUANTITY_SPEC(radiance, radiant_intensity / area); QUANTITY_SPEC(radiance, radiant_intensity / area);

View File

@@ -37,24 +37,24 @@ MP_UNITS_EXPORT
namespace mp_units::isq { namespace mp_units::isq {
QUANTITY_SPEC(mass_density, mass / volume); QUANTITY_SPEC(mass_density, mass / volume);
inline constexpr auto density = mass_density; constexpr auto density = mass_density;
QUANTITY_SPEC(specific_volume, inverse(mass_density)); QUANTITY_SPEC(specific_volume, inverse(mass_density));
QUANTITY_SPEC(relative_mass_density, mass_density / mass_density); QUANTITY_SPEC(relative_mass_density, mass_density / mass_density);
inline constexpr auto relative_density = relative_mass_density; constexpr auto relative_density = relative_mass_density;
QUANTITY_SPEC(surface_mass_density, mass / area); QUANTITY_SPEC(surface_mass_density, mass / area);
inline constexpr auto surface_density = surface_mass_density; constexpr auto surface_density = surface_mass_density;
QUANTITY_SPEC(linear_mass_density, mass / length); QUANTITY_SPEC(linear_mass_density, mass / length);
inline constexpr auto linear_density = linear_mass_density; constexpr auto linear_density = linear_mass_density;
QUANTITY_SPEC(momentum, mass* velocity); // vector QUANTITY_SPEC(momentum, mass* velocity); // vector
QUANTITY_SPEC(force, mass* acceleration); // vector // TODO what is a correct equation here? QUANTITY_SPEC(force, mass* acceleration); // vector // TODO what is a correct equation here?
QUANTITY_SPEC(weight, force, mass* acceleration_of_free_fall); // vector // differs from ISO 80000 QUANTITY_SPEC(weight, force, mass* acceleration_of_free_fall); // vector // differs from ISO 80000
QUANTITY_SPEC(static_friction_force, force); // vector QUANTITY_SPEC(static_friction_force, force); // vector
inline constexpr auto static_friction = static_friction_force; constexpr auto static_friction = static_friction_force;
QUANTITY_SPEC(kinetic_friction_force, force); // vector QUANTITY_SPEC(kinetic_friction_force, force); // vector
inline constexpr auto dynamic_friction_force = kinetic_friction_force; constexpr auto dynamic_friction_force = kinetic_friction_force;
QUANTITY_SPEC(rolling_resistance, force); // vector QUANTITY_SPEC(rolling_resistance, force); // vector
inline constexpr auto rolling_drag = rolling_resistance; constexpr auto rolling_drag = rolling_resistance;
inline constexpr auto rolling_friction_force = rolling_resistance; constexpr auto rolling_friction_force = rolling_resistance;
QUANTITY_SPEC(drag_force, force); // vector QUANTITY_SPEC(drag_force, force); // vector
QUANTITY_SPEC(impulse, force* time); // vector QUANTITY_SPEC(impulse, force* time); // vector
QUANTITY_SPEC(angular_momentum, position_vector* momentum); // vector QUANTITY_SPEC(angular_momentum, position_vector* momentum); // vector
@@ -73,24 +73,24 @@ QUANTITY_SPEC(shear_strain, dimensionless, displacement / thickness, quantity_ch
QUANTITY_SPEC(relative_volume_strain, volume / volume); QUANTITY_SPEC(relative_volume_strain, volume / volume);
QUANTITY_SPEC(Poisson_number, dimensionless, width / length); QUANTITY_SPEC(Poisson_number, dimensionless, width / length);
QUANTITY_SPEC(modulus_of_elasticity, normal_stress / relative_linear_strain); QUANTITY_SPEC(modulus_of_elasticity, normal_stress / relative_linear_strain);
inline constexpr auto Young_modulus = modulus_of_elasticity; constexpr auto Young_modulus = modulus_of_elasticity;
QUANTITY_SPEC(modulus_of_rigidity, shear_stress / shear_strain); QUANTITY_SPEC(modulus_of_rigidity, shear_stress / shear_strain);
inline constexpr auto shear_modulus = modulus_of_rigidity; constexpr auto shear_modulus = modulus_of_rigidity;
QUANTITY_SPEC(modulus_of_compression, pressure / relative_volume_strain); QUANTITY_SPEC(modulus_of_compression, pressure / relative_volume_strain);
inline constexpr auto bulk_modulus = modulus_of_compression; constexpr auto bulk_modulus = modulus_of_compression;
QUANTITY_SPEC(compressibility, inverse(volume) * (volume / pressure)); QUANTITY_SPEC(compressibility, inverse(volume) * (volume / pressure));
QUANTITY_SPEC(second_axial_moment_of_area, pow<2>(radial_distance) * area); QUANTITY_SPEC(second_axial_moment_of_area, pow<2>(radial_distance) * area);
QUANTITY_SPEC(second_polar_moment_of_area, pow<2>(radial_distance) * area); QUANTITY_SPEC(second_polar_moment_of_area, pow<2>(radial_distance) * area);
QUANTITY_SPEC(section_modulus, second_axial_moment_of_area / radial_distance); QUANTITY_SPEC(section_modulus, second_axial_moment_of_area / radial_distance);
QUANTITY_SPEC(static_friction_coefficient, dimensionless, static_friction_force / force, quantity_character::scalar); QUANTITY_SPEC(static_friction_coefficient, dimensionless, static_friction_force / force, quantity_character::scalar);
inline constexpr auto static_friction_factor = static_friction_coefficient; constexpr auto static_friction_factor = static_friction_coefficient;
inline constexpr auto coefficient_of_static_friction = static_friction_coefficient; constexpr auto coefficient_of_static_friction = static_friction_coefficient;
QUANTITY_SPEC(kinetic_friction_factor, dimensionless, kinetic_friction_force / force, quantity_character::scalar); QUANTITY_SPEC(kinetic_friction_factor, dimensionless, kinetic_friction_force / force, quantity_character::scalar);
inline constexpr auto dynamic_friction_factor = kinetic_friction_factor; constexpr auto dynamic_friction_factor = kinetic_friction_factor;
QUANTITY_SPEC(rolling_resistance_factor, force / force, quantity_character::scalar); QUANTITY_SPEC(rolling_resistance_factor, force / force, quantity_character::scalar);
QUANTITY_SPEC(drag_coefficient, dimensionless, drag_force / (mass_density * pow<2>(speed) * area), QUANTITY_SPEC(drag_coefficient, dimensionless, drag_force / (mass_density * pow<2>(speed) * area),
quantity_character::scalar); quantity_character::scalar);
inline constexpr auto drag_factor = drag_coefficient; constexpr auto drag_factor = drag_coefficient;
QUANTITY_SPEC(dynamic_viscosity, shear_stress* length / velocity, quantity_character::scalar); QUANTITY_SPEC(dynamic_viscosity, shear_stress* length / velocity, quantity_character::scalar);
QUANTITY_SPEC(kinematic_viscosity, dynamic_viscosity / mass_density); QUANTITY_SPEC(kinematic_viscosity, dynamic_viscosity / mass_density);
QUANTITY_SPEC(surface_tension, force / length, quantity_character::scalar); // TODO what is a correct equation here? QUANTITY_SPEC(surface_tension, force / length, quantity_character::scalar); // TODO what is a correct equation here?
@@ -100,7 +100,7 @@ QUANTITY_SPEC(mechanical_energy, energy); // diffe
QUANTITY_SPEC(potential_energy, mechanical_energy); // differs from ISO 80000 QUANTITY_SPEC(potential_energy, mechanical_energy); // differs from ISO 80000
QUANTITY_SPEC(kinetic_energy, mechanical_energy, mass* pow<2>(speed)); // differs from ISO 80000 QUANTITY_SPEC(kinetic_energy, mechanical_energy, mass* pow<2>(speed)); // differs from ISO 80000
QUANTITY_SPEC(mechanical_work, force* displacement, quantity_character::scalar); QUANTITY_SPEC(mechanical_work, force* displacement, quantity_character::scalar);
inline constexpr auto work = mechanical_work; constexpr auto work = mechanical_work;
QUANTITY_SPEC(mechanical_efficiency, mechanical_power / mechanical_power); QUANTITY_SPEC(mechanical_efficiency, mechanical_power / mechanical_power);
QUANTITY_SPEC(mass_flow, mass_density* velocity); // vector QUANTITY_SPEC(mass_flow, mass_density* velocity); // vector
QUANTITY_SPEC(mass_flow_rate, mass_flow* area, quantity_character::scalar); QUANTITY_SPEC(mass_flow_rate, mass_flow* area, quantity_character::scalar);

View File

@@ -37,15 +37,15 @@ namespace mp_units::isq {
// space and time // space and time
QUANTITY_SPEC(width, length); QUANTITY_SPEC(width, length);
inline constexpr auto breadth = width; constexpr auto breadth = width;
QUANTITY_SPEC(radius, width); // differs from ISO 80000 QUANTITY_SPEC(radius, width); // differs from ISO 80000
QUANTITY_SPEC(path_length, length); QUANTITY_SPEC(path_length, length);
inline constexpr auto arc_length = path_length; constexpr auto arc_length = path_length;
QUANTITY_SPEC(area, pow<2>(length)); QUANTITY_SPEC(area, pow<2>(length));
QUANTITY_SPEC(angular_measure, dimensionless, arc_length / radius, is_kind); QUANTITY_SPEC(angular_measure, dimensionless, arc_length / radius, is_kind);
QUANTITY_SPEC(solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind); QUANTITY_SPEC(solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind);
QUANTITY_SPEC(period_duration, duration); QUANTITY_SPEC(period_duration, duration);
inline constexpr auto period = period_duration; constexpr auto period = period_duration;
QUANTITY_SPEC(frequency, inverse(period_duration)); QUANTITY_SPEC(frequency, inverse(period_duration));
// mechanics // mechanics

View File

@@ -36,8 +36,8 @@ MP_UNITS_EXPORT
namespace mp_units::isq { namespace mp_units::isq {
QUANTITY_SPEC(height, length); QUANTITY_SPEC(height, length);
inline constexpr auto depth = height; constexpr auto depth = height;
inline constexpr auto altitude = height; constexpr auto altitude = height;
QUANTITY_SPEC(thickness, width); QUANTITY_SPEC(thickness, width);
QUANTITY_SPEC(diameter, width); QUANTITY_SPEC(diameter, width);
QUANTITY_SPEC(distance, path_length); QUANTITY_SPEC(distance, path_length);
@@ -48,7 +48,7 @@ QUANTITY_SPEC(radius_of_curvature, radius);
QUANTITY_SPEC(curvature, inverse(radius_of_curvature)); QUANTITY_SPEC(curvature, inverse(radius_of_curvature));
QUANTITY_SPEC(volume, pow<3>(length)); QUANTITY_SPEC(volume, pow<3>(length));
QUANTITY_SPEC(rotational_displacement, angular_measure, path_length / radius); QUANTITY_SPEC(rotational_displacement, angular_measure, path_length / radius);
inline constexpr auto angular_displacement = rotational_displacement; constexpr auto angular_displacement = rotational_displacement;
QUANTITY_SPEC(phase_angle, angular_measure); QUANTITY_SPEC(phase_angle, angular_measure);
QUANTITY_SPEC(speed, length / time); // differs from ISO 80000 QUANTITY_SPEC(speed, length / time); // differs from ISO 80000
QUANTITY_SPEC(velocity, speed, position_vector / duration); // vector // differs from ISO 80000 QUANTITY_SPEC(velocity, speed, position_vector / duration); // vector // differs from ISO 80000
@@ -62,18 +62,18 @@ QUANTITY_SPEC(rotational_frequency, rotation / duration);
QUANTITY_SPEC(angular_frequency, phase_angle / duration); QUANTITY_SPEC(angular_frequency, phase_angle / duration);
QUANTITY_SPEC(wavelength, length); QUANTITY_SPEC(wavelength, length);
QUANTITY_SPEC(repetency, inverse(wavelength)); QUANTITY_SPEC(repetency, inverse(wavelength));
inline constexpr auto wavenumber = repetency; constexpr auto wavenumber = repetency;
QUANTITY_SPEC(wave_vector, repetency, quantity_character::vector); QUANTITY_SPEC(wave_vector, repetency, quantity_character::vector);
QUANTITY_SPEC(angular_repetency, inverse(wavelength)); QUANTITY_SPEC(angular_repetency, inverse(wavelength));
inline constexpr auto angular_wavenumber = angular_repetency; constexpr auto angular_wavenumber = angular_repetency;
QUANTITY_SPEC(phase_velocity, angular_frequency / angular_repetency); QUANTITY_SPEC(phase_velocity, angular_frequency / angular_repetency);
inline constexpr auto phase_speed = phase_velocity; constexpr auto phase_speed = phase_velocity;
QUANTITY_SPEC(group_velocity, angular_frequency / angular_repetency); QUANTITY_SPEC(group_velocity, angular_frequency / angular_repetency);
inline constexpr auto group_speed = group_velocity; constexpr auto group_speed = group_velocity;
QUANTITY_SPEC(damping_coefficient, inverse(time_constant)); QUANTITY_SPEC(damping_coefficient, inverse(time_constant));
QUANTITY_SPEC(logarithmic_decrement, dimensionless, damping_coefficient* period_duration); QUANTITY_SPEC(logarithmic_decrement, dimensionless, damping_coefficient* period_duration);
QUANTITY_SPEC(attenuation, inverse(distance)); QUANTITY_SPEC(attenuation, inverse(distance));
inline constexpr auto extinction = attenuation; constexpr auto extinction = attenuation;
QUANTITY_SPEC(phase_coefficient, phase_angle / path_length); QUANTITY_SPEC(phase_coefficient, phase_angle / path_length);
QUANTITY_SPEC(propagation_coefficient, inverse(length)); // γ = α + iβ where α denotes attenuation QUANTITY_SPEC(propagation_coefficient, inverse(length)); // γ = α + iβ where α denotes attenuation
// and β the phase coefficient of a plane wave // and β the phase coefficient of a plane wave

View File

@@ -46,7 +46,7 @@ QUANTITY_SPEC(isothermal_compressibility, inverse(volume) * (volume / pressure))
QUANTITY_SPEC(isentropic_compressibility, inverse(volume) * (volume / pressure)); // TODO how to handle "negative" part QUANTITY_SPEC(isentropic_compressibility, inverse(volume) * (volume / pressure)); // TODO how to handle "negative" part
// energy definition moved to mechanics // energy definition moved to mechanics
QUANTITY_SPEC(heat, energy); QUANTITY_SPEC(heat, energy);
inline constexpr auto amount_of_heat = heat; constexpr auto amount_of_heat = heat;
QUANTITY_SPEC(latent_heat, heat); // TODO what is a correct equation here? QUANTITY_SPEC(latent_heat, heat); // TODO what is a correct equation here?
QUANTITY_SPEC(heat_flow_rate, heat / time); QUANTITY_SPEC(heat_flow_rate, heat / time);
QUANTITY_SPEC(density_of_heat_flow_rate, heat_flow_rate / area); QUANTITY_SPEC(density_of_heat_flow_rate, heat_flow_rate / area);
@@ -54,7 +54,7 @@ QUANTITY_SPEC(thermal_conductivity, density_of_heat_flow_rate*(length / thermody
QUANTITY_SPEC(coefficient_of_heat_transfer, density_of_heat_flow_rate / thermodynamic_temperature); QUANTITY_SPEC(coefficient_of_heat_transfer, density_of_heat_flow_rate / thermodynamic_temperature);
QUANTITY_SPEC(surface_coefficient_of_heat_transfer, density_of_heat_flow_rate / thermodynamic_temperature); QUANTITY_SPEC(surface_coefficient_of_heat_transfer, density_of_heat_flow_rate / thermodynamic_temperature);
QUANTITY_SPEC(thermal_insulance, inverse(coefficient_of_heat_transfer)); QUANTITY_SPEC(thermal_insulance, inverse(coefficient_of_heat_transfer));
inline constexpr auto coefficient_of_thermal_insulance = thermal_insulance; constexpr auto coefficient_of_thermal_insulance = thermal_insulance;
QUANTITY_SPEC(thermal_resistance, thermodynamic_temperature / heat_flow_rate); QUANTITY_SPEC(thermal_resistance, thermodynamic_temperature / heat_flow_rate);
QUANTITY_SPEC(thermal_conductance, inverse(thermal_resistance)); QUANTITY_SPEC(thermal_conductance, inverse(thermal_resistance));
QUANTITY_SPEC(heat_capacity, heat / thermodynamic_temperature); QUANTITY_SPEC(heat_capacity, heat / thermodynamic_temperature);
@@ -67,24 +67,24 @@ QUANTITY_SPEC(ratio_of_specific_heat_capacities, dimensionless,
specific_heat_capacity_at_constant_pressure / specific_heat_capacity_at_constant_volume); specific_heat_capacity_at_constant_pressure / specific_heat_capacity_at_constant_volume);
QUANTITY_SPEC(isentropic_exponent, QUANTITY_SPEC(isentropic_exponent,
volume / pressure * (pressure / volume)); // TODO how to handle "negative" part volume / pressure * (pressure / volume)); // TODO how to handle "negative" part
inline constexpr auto isentropic_expansion_factor = isentropic_exponent; constexpr auto isentropic_expansion_factor = isentropic_exponent;
QUANTITY_SPEC(entropy, kinetic_energy / thermodynamic_temperature); QUANTITY_SPEC(entropy, kinetic_energy / thermodynamic_temperature);
QUANTITY_SPEC(specific_entropy, entropy / mass); QUANTITY_SPEC(specific_entropy, entropy / mass);
QUANTITY_SPEC(enthalpy, energy); // differs from ISO 80000 QUANTITY_SPEC(enthalpy, energy); // differs from ISO 80000
QUANTITY_SPEC(internal_energy, enthalpy); // differs from ISO 80000 QUANTITY_SPEC(internal_energy, enthalpy); // differs from ISO 80000
inline constexpr auto thermodynamic_energy = internal_energy; constexpr auto thermodynamic_energy = internal_energy;
QUANTITY_SPEC(Helmholtz_energy, internal_energy); QUANTITY_SPEC(Helmholtz_energy, internal_energy);
inline constexpr auto Helmholtz_function = Helmholtz_energy; constexpr auto Helmholtz_function = Helmholtz_energy;
QUANTITY_SPEC(Gibbs_energy, enthalpy); QUANTITY_SPEC(Gibbs_energy, enthalpy);
inline constexpr auto Gibbs_function = Gibbs_energy; constexpr auto Gibbs_function = Gibbs_energy;
QUANTITY_SPEC(specific_energy, energy / mass); QUANTITY_SPEC(specific_energy, energy / mass);
QUANTITY_SPEC(specific_internal_energy, internal_energy / mass); QUANTITY_SPEC(specific_internal_energy, internal_energy / mass);
inline constexpr auto specific_thermodynamic_energy = specific_internal_energy; constexpr auto specific_thermodynamic_energy = specific_internal_energy;
QUANTITY_SPEC(specific_enthalpy, enthalpy / mass); QUANTITY_SPEC(specific_enthalpy, enthalpy / mass);
QUANTITY_SPEC(specific_Helmholtz_energy, Helmholtz_energy / mass); QUANTITY_SPEC(specific_Helmholtz_energy, Helmholtz_energy / mass);
inline constexpr auto specific_Helmholtz_function = specific_Helmholtz_energy; constexpr auto specific_Helmholtz_function = specific_Helmholtz_energy;
QUANTITY_SPEC(specific_Gibbs_energy, Gibbs_energy / mass); QUANTITY_SPEC(specific_Gibbs_energy, Gibbs_energy / mass);
inline constexpr auto specific_Gibbs_function = specific_Gibbs_energy; constexpr auto specific_Gibbs_function = specific_Gibbs_energy;
QUANTITY_SPEC(Massieu_function, Helmholtz_energy / thermodynamic_temperature); // TODO how to handle "negative" part QUANTITY_SPEC(Massieu_function, Helmholtz_energy / thermodynamic_temperature); // TODO how to handle "negative" part
QUANTITY_SPEC(Planck_function, Gibbs_energy / thermodynamic_temperature); // TODO how to handle "negative" part QUANTITY_SPEC(Planck_function, Gibbs_energy / thermodynamic_temperature); // TODO how to handle "negative" part
QUANTITY_SPEC(Joule_Thomson_coefficient, thermodynamic_temperature / pressure); QUANTITY_SPEC(Joule_Thomson_coefficient, thermodynamic_temperature / pressure);

View File

@@ -43,7 +43,7 @@ using namespace isq;
QUANTITY_SPEC(cotes_angle_constant, angular::angle); // 1 rad QUANTITY_SPEC(cotes_angle_constant, angular::angle); // 1 rad
QUANTITY_SPEC(angular_measure, angular::angle, cotes_angle_constant* arc_length / radius); QUANTITY_SPEC(angular_measure, angular::angle, cotes_angle_constant* arc_length / radius);
QUANTITY_SPEC(rotational_displacement, angular::angle, cotes_angle_constant* path_length / radius); QUANTITY_SPEC(rotational_displacement, angular::angle, cotes_angle_constant* path_length / radius);
inline constexpr auto angular_displacement = rotational_displacement; constexpr auto angular_displacement = rotational_displacement;
QUANTITY_SPEC(phase_angle, angular_measure); QUANTITY_SPEC(phase_angle, angular_measure);
QUANTITY_SPEC(solid_angular_measure, pow<2>(cotes_angle_constant) * area / pow<2>(radius)); QUANTITY_SPEC(solid_angular_measure, pow<2>(cotes_angle_constant) * area / pow<2>(radius));
QUANTITY_SPEC(angular_velocity, angular_displacement / duration, quantity_character::vector); QUANTITY_SPEC(angular_velocity, angular_displacement / duration, quantity_character::vector);
@@ -51,7 +51,7 @@ QUANTITY_SPEC(angular_acceleration, angular_velocity / duration);
QUANTITY_SPEC(rotation, rotational_displacement); QUANTITY_SPEC(rotation, rotational_displacement);
QUANTITY_SPEC(angular_frequency, phase_angle / duration); QUANTITY_SPEC(angular_frequency, phase_angle / duration);
QUANTITY_SPEC(angular_repetency, cotes_angle_constant / wavelength); QUANTITY_SPEC(angular_repetency, cotes_angle_constant / wavelength);
inline constexpr auto angular_wavenumber = angular_repetency; constexpr auto angular_wavenumber = angular_repetency;
QUANTITY_SPEC(phase_coefficient, phase_angle / path_length); QUANTITY_SPEC(phase_coefficient, phase_angle / path_length);
QUANTITY_SPEC(propagation_coefficient, cotes_angle_constant / length); QUANTITY_SPEC(propagation_coefficient, cotes_angle_constant / length);
QUANTITY_SPEC(angular_momentum, position_vector* momentum / cotes_angle_constant); // vector QUANTITY_SPEC(angular_momentum, position_vector* momentum / cotes_angle_constant); // vector
@@ -62,6 +62,6 @@ QUANTITY_SPEC(angular_impulse, moment_of_force* time); // vector
QUANTITY_SPEC(loss_angle, angular_measure); QUANTITY_SPEC(loss_angle, angular_measure);
// constants // constants
inline constexpr auto cotes_angle = cotes_angle_constant[angular::radian]; constexpr auto cotes_angle = cotes_angle_constant[angular::radian];
} // namespace mp_units::isq_angle } // namespace mp_units::isq_angle

View File

@@ -38,28 +38,28 @@ namespace mp_units::natural {
// clang-format off // clang-format off
// units // units
inline constexpr struct electronvolt final : named_unit<"eV"> {} electronvolt; constexpr struct electronvolt final : named_unit<"eV"> {} electronvolt;
inline constexpr auto gigaelectronvolt = si::giga<electronvolt>; constexpr auto gigaelectronvolt = si::giga<electronvolt>;
// system references // system references
inline constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time; constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time;
inline constexpr struct length : system_reference<isq::length, inverse(gigaelectronvolt)> {} length; constexpr struct length : system_reference<isq::length, inverse(gigaelectronvolt)> {} length;
inline constexpr struct mass : system_reference<isq::mass, gigaelectronvolt> {} mass; constexpr struct mass : system_reference<isq::mass, gigaelectronvolt> {} mass;
inline constexpr struct velocity : system_reference<isq::velocity, one> {} velocity; constexpr struct velocity : system_reference<isq::velocity, one> {} velocity;
inline constexpr struct speed : system_reference<isq::speed, one> {} speed; constexpr struct speed : system_reference<isq::speed, one> {} speed;
inline constexpr struct acceleration : system_reference<isq::acceleration, gigaelectronvolt> {} acceleration; constexpr struct acceleration : system_reference<isq::acceleration, gigaelectronvolt> {} acceleration;
inline constexpr struct momentum : system_reference<isq::momentum, gigaelectronvolt> {} momentum; constexpr struct momentum : system_reference<isq::momentum, gigaelectronvolt> {} momentum;
inline constexpr struct force : system_reference<isq::force, square(gigaelectronvolt)> {} force; constexpr struct force : system_reference<isq::force, square(gigaelectronvolt)> {} force;
inline constexpr struct energy : system_reference<isq::mechanical_energy, gigaelectronvolt> {} energy; constexpr struct energy : system_reference<isq::mechanical_energy, gigaelectronvolt> {} energy;
// clang-format on // clang-format on
// constants // constants
inline constexpr auto speed_of_light = speed[one]; constexpr auto speed_of_light = speed[one];
namespace unit_symbols { namespace unit_symbols {
inline constexpr auto GeV = gigaelectronvolt; constexpr auto GeV = gigaelectronvolt;
inline constexpr auto GeV2 = square(gigaelectronvolt); constexpr auto GeV2 = square(gigaelectronvolt);
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -93,7 +93,7 @@ struct chrono_point_origin_ final : absolute_point_origin<isq::time> {
using clock = C; using clock = C;
}; };
MP_UNITS_EXPORT template<typename C> MP_UNITS_EXPORT template<typename C>
inline constexpr chrono_point_origin_<C> chrono_point_origin; constexpr chrono_point_origin_<C> chrono_point_origin;
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN

View File

@@ -35,28 +35,28 @@ namespace mp_units::si {
namespace si2019 { namespace si2019 {
// clang-format off // clang-format off
inline constexpr struct hyperfine_structure_transition_frequency_of_cs final : constexpr struct hyperfine_structure_transition_frequency_of_cs final :
named_unit<symbol_text{u8"Δν_Cs", "dv_Cs"}, mag<9'192'631'770> * hertz> {} hyperfine_structure_transition_frequency_of_cs; named_unit<symbol_text{u8"Δν_Cs", "dv_Cs"}, mag<9'192'631'770> * hertz> {} hyperfine_structure_transition_frequency_of_cs;
inline constexpr struct speed_of_light_in_vacuum final : constexpr struct speed_of_light_in_vacuum final :
named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
inline constexpr struct planck_constant final : constexpr struct planck_constant final :
named_unit<"h", mag_ratio<662'607'015, 100'000'000> * mag_power<10, -34> * joule * second> {} planck_constant; named_unit<"h", mag_ratio<662'607'015, 100'000'000> * mag_power<10, -34> * joule * second> {} planck_constant;
inline constexpr struct elementary_charge final : constexpr struct elementary_charge final :
named_unit<"e", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * coulomb> {} elementary_charge; named_unit<"e", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * coulomb> {} elementary_charge;
inline constexpr struct boltzmann_constant final : constexpr struct boltzmann_constant final :
named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant; named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_constant;
inline constexpr struct avogadro_constant final : constexpr struct avogadro_constant final :
named_unit<"N_A", mag_ratio<602'214'076, 100'000'000> * mag_power<10, 23> / mole> {} avogadro_constant; named_unit<"N_A", mag_ratio<602'214'076, 100'000'000> * mag_power<10, 23> / mole> {} avogadro_constant;
inline constexpr struct luminous_efficacy final : constexpr struct luminous_efficacy final :
named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy; named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
// clang-format on // clang-format on
} // namespace si2019 } // namespace si2019
// clang-format off // clang-format off
inline constexpr struct standard_gravity final : constexpr struct standard_gravity final :
named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity; named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity;
inline constexpr struct magnetic_constant final : constexpr struct magnetic_constant final :
named_unit<symbol_text{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant; named_unit<symbol_text{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant;
// clang-format on // clang-format on

View File

@@ -58,30 +58,30 @@ template<PrefixableUnit U> struct quetta_ final : prefixed_unit<"Q", mag_power<1
MP_UNITS_EXPORT_BEGIN MP_UNITS_EXPORT_BEGIN
template<PrefixableUnit auto U> inline constexpr quecto_<MP_UNITS_REMOVE_CONST(decltype(U))> quecto; template<PrefixableUnit auto U> constexpr quecto_<MP_UNITS_REMOVE_CONST(decltype(U))> quecto;
template<PrefixableUnit auto U> inline constexpr ronto_<MP_UNITS_REMOVE_CONST(decltype(U))> ronto; template<PrefixableUnit auto U> constexpr ronto_<MP_UNITS_REMOVE_CONST(decltype(U))> ronto;
template<PrefixableUnit auto U> inline constexpr yocto_<MP_UNITS_REMOVE_CONST(decltype(U))> yocto; template<PrefixableUnit auto U> constexpr yocto_<MP_UNITS_REMOVE_CONST(decltype(U))> yocto;
template<PrefixableUnit auto U> inline constexpr zepto_<MP_UNITS_REMOVE_CONST(decltype(U))> zepto; template<PrefixableUnit auto U> constexpr zepto_<MP_UNITS_REMOVE_CONST(decltype(U))> zepto;
template<PrefixableUnit auto U> inline constexpr atto_<MP_UNITS_REMOVE_CONST(decltype(U))> atto; template<PrefixableUnit auto U> constexpr atto_<MP_UNITS_REMOVE_CONST(decltype(U))> atto;
template<PrefixableUnit auto U> inline constexpr femto_<MP_UNITS_REMOVE_CONST(decltype(U))> femto; template<PrefixableUnit auto U> constexpr femto_<MP_UNITS_REMOVE_CONST(decltype(U))> femto;
template<PrefixableUnit auto U> inline constexpr pico_<MP_UNITS_REMOVE_CONST(decltype(U))> pico; template<PrefixableUnit auto U> constexpr pico_<MP_UNITS_REMOVE_CONST(decltype(U))> pico;
template<PrefixableUnit auto U> inline constexpr nano_<MP_UNITS_REMOVE_CONST(decltype(U))> nano; template<PrefixableUnit auto U> constexpr nano_<MP_UNITS_REMOVE_CONST(decltype(U))> nano;
template<PrefixableUnit auto U> inline constexpr micro_<MP_UNITS_REMOVE_CONST(decltype(U))> micro; template<PrefixableUnit auto U> constexpr micro_<MP_UNITS_REMOVE_CONST(decltype(U))> micro;
template<PrefixableUnit auto U> inline constexpr milli_<MP_UNITS_REMOVE_CONST(decltype(U))> milli; template<PrefixableUnit auto U> constexpr milli_<MP_UNITS_REMOVE_CONST(decltype(U))> milli;
template<PrefixableUnit auto U> inline constexpr centi_<MP_UNITS_REMOVE_CONST(decltype(U))> centi; template<PrefixableUnit auto U> constexpr centi_<MP_UNITS_REMOVE_CONST(decltype(U))> centi;
template<PrefixableUnit auto U> inline constexpr deci_<MP_UNITS_REMOVE_CONST(decltype(U))> deci; template<PrefixableUnit auto U> constexpr deci_<MP_UNITS_REMOVE_CONST(decltype(U))> deci;
template<PrefixableUnit auto U> inline constexpr deca_<MP_UNITS_REMOVE_CONST(decltype(U))> deca; template<PrefixableUnit auto U> constexpr deca_<MP_UNITS_REMOVE_CONST(decltype(U))> deca;
template<PrefixableUnit auto U> inline constexpr hecto_<MP_UNITS_REMOVE_CONST(decltype(U))> hecto; template<PrefixableUnit auto U> constexpr hecto_<MP_UNITS_REMOVE_CONST(decltype(U))> hecto;
template<PrefixableUnit auto U> inline constexpr kilo_<MP_UNITS_REMOVE_CONST(decltype(U))> kilo; template<PrefixableUnit auto U> constexpr kilo_<MP_UNITS_REMOVE_CONST(decltype(U))> kilo;
template<PrefixableUnit auto U> inline constexpr mega_<MP_UNITS_REMOVE_CONST(decltype(U))> mega; template<PrefixableUnit auto U> constexpr mega_<MP_UNITS_REMOVE_CONST(decltype(U))> mega;
template<PrefixableUnit auto U> inline constexpr giga_<MP_UNITS_REMOVE_CONST(decltype(U))> giga; template<PrefixableUnit auto U> constexpr giga_<MP_UNITS_REMOVE_CONST(decltype(U))> giga;
template<PrefixableUnit auto U> inline constexpr tera_<MP_UNITS_REMOVE_CONST(decltype(U))> tera; template<PrefixableUnit auto U> constexpr tera_<MP_UNITS_REMOVE_CONST(decltype(U))> tera;
template<PrefixableUnit auto U> inline constexpr peta_<MP_UNITS_REMOVE_CONST(decltype(U))> peta; template<PrefixableUnit auto U> constexpr peta_<MP_UNITS_REMOVE_CONST(decltype(U))> peta;
template<PrefixableUnit auto U> inline constexpr exa_<MP_UNITS_REMOVE_CONST(decltype(U))> exa; template<PrefixableUnit auto U> constexpr exa_<MP_UNITS_REMOVE_CONST(decltype(U))> exa;
template<PrefixableUnit auto U> inline constexpr zetta_<MP_UNITS_REMOVE_CONST(decltype(U))> zetta; template<PrefixableUnit auto U> constexpr zetta_<MP_UNITS_REMOVE_CONST(decltype(U))> zetta;
template<PrefixableUnit auto U> inline constexpr yotta_<MP_UNITS_REMOVE_CONST(decltype(U))> yotta; template<PrefixableUnit auto U> constexpr yotta_<MP_UNITS_REMOVE_CONST(decltype(U))> yotta;
template<PrefixableUnit auto U> inline constexpr ronna_<MP_UNITS_REMOVE_CONST(decltype(U))> ronna; template<PrefixableUnit auto U> constexpr ronna_<MP_UNITS_REMOVE_CONST(decltype(U))> ronna;
template<PrefixableUnit auto U> inline constexpr quetta_<MP_UNITS_REMOVE_CONST(decltype(U))> quetta; template<PrefixableUnit auto U> constexpr quetta_<MP_UNITS_REMOVE_CONST(decltype(U))> quetta;
// clang-format on // clang-format on
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END

File diff suppressed because it is too large Load Diff

View File

@@ -39,55 +39,55 @@ namespace si {
// clang-format off // clang-format off
// base units // base units
inline constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second; constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
inline constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre; constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram; constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
inline constexpr auto kilogram = kilo<gram>; constexpr auto kilogram = kilo<gram>;
inline constexpr struct ampere final : named_unit<"A", kind_of<isq::electric_current>> {} ampere; constexpr struct ampere final : named_unit<"A", kind_of<isq::electric_current>> {} ampere;
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero; constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
inline constexpr auto zeroth_kelvin = absolute_zero; constexpr auto zeroth_kelvin = absolute_zero;
inline constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin; constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
inline constexpr struct mole final : named_unit<"mol", kind_of<isq::amount_of_substance>> {} mole; constexpr struct mole final : named_unit<"mol", kind_of<isq::amount_of_substance>> {} mole;
inline constexpr struct candela final : named_unit<"cd", kind_of<isq::luminous_intensity>> {} candela; constexpr struct candela final : named_unit<"cd", kind_of<isq::luminous_intensity>> {} candela;
// derived named units // derived named units
inline constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian; constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
inline constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian; constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
inline constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz; constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
#ifdef pascal #ifdef pascal
#pragma push_macro("pascal") #pragma push_macro("pascal")
#undef pascal #undef pascal
#define MP_UNITS_REDEFINE_PASCAL #define MP_UNITS_REDEFINE_PASCAL
#endif #endif
inline constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal; constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
#ifdef MP_UNITS_REDEFINE_PASCAL #ifdef MP_UNITS_REDEFINE_PASCAL
#pragma pop_macro("pascal") #pragma pop_macro("pascal")
#undef MP_UNITS_REDEFINE_PASCAL #undef MP_UNITS_REDEFINE_PASCAL
#endif #endif
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule; constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt; constexpr struct watt final : named_unit<"W", joule / second> {} watt;
inline constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb; constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
inline constexpr struct volt final : named_unit<"V", watt / ampere> {} volt; constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
inline constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad; constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm; constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
inline constexpr struct siemens final : named_unit<"S", one / ohm> {} siemens; constexpr struct siemens final : named_unit<"S", one / ohm> {} siemens;
inline constexpr struct weber final : named_unit<"Wb", volt * second> {} weber; constexpr struct weber final : named_unit<"Wb", volt * second> {} weber;
inline constexpr struct tesla final : named_unit<"T", weber / square(metre)> {} tesla; constexpr struct tesla final : named_unit<"T", weber / square(metre)> {} tesla;
inline constexpr struct henry final : named_unit<"H", weber / ampere> {} henry; constexpr struct henry final : named_unit<"H", weber / ampere> {} henry;
inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point; constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
inline constexpr auto zeroth_degree_Celsius = ice_point; constexpr auto zeroth_degree_Celsius = ice_point;
inline constexpr struct degree_Celsius final : named_unit<symbol_text{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; constexpr struct degree_Celsius final : named_unit<symbol_text{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
inline constexpr struct lumen final : named_unit<"lm", candela * steradian> {} lumen; constexpr struct lumen final : named_unit<"lm", candela * steradian> {} lumen;
inline constexpr struct lux final : named_unit<"lx", lumen / square(metre)> {} lux; constexpr struct lux final : named_unit<"lx", lumen / square(metre)> {} lux;
inline constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel; constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel;
inline constexpr struct gray final : named_unit<"Gy", joule / kilogram, kind_of<isq::absorbed_dose>> {} gray; constexpr struct gray final : named_unit<"Gy", joule / kilogram, kind_of<isq::absorbed_dose>> {} gray;
inline constexpr struct sievert final : named_unit<"Sv", joule / kilogram, kind_of<isq::dose_equivalent>> {} sievert; constexpr struct sievert final : named_unit<"Sv", joule / kilogram, kind_of<isq::dose_equivalent>> {} sievert;
inline constexpr struct katal final : named_unit<"kat", mole / second> {} katal; constexpr struct katal final : named_unit<"kat", mole / second> {} katal;
// clang-format on // clang-format on
} // namespace si } // namespace si
@@ -96,20 +96,20 @@ namespace non_si {
// clang-format off // clang-format off
// non-SI units accepted for use with the SI // non-SI units accepted for use with the SI
inline constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute; constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
inline constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour; constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour;
inline constexpr struct day final : named_unit<"d", mag<24> * hour> {} day; constexpr struct day final : named_unit<"d", mag<24> * hour> {} day;
inline constexpr struct astronomical_unit final : named_unit<"au", mag<149'597'870'700> * si::metre> {} astronomical_unit; constexpr struct astronomical_unit final : named_unit<"au", mag<149'597'870'700> * si::metre> {} astronomical_unit;
inline constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree; constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
inline constexpr struct arcminute final : named_unit<symbol_text{u8"", "'"}, mag_ratio<1, 60> * degree> {} arcminute; constexpr struct arcminute final : named_unit<symbol_text{u8"", "'"}, mag_ratio<1, 60> * degree> {} arcminute;
inline constexpr struct arcsecond final : named_unit<symbol_text{u8"", "''"}, mag_ratio<1, 60> * arcminute> {} arcsecond; constexpr struct arcsecond final : named_unit<symbol_text{u8"", "''"}, mag_ratio<1, 60> * arcminute> {} arcsecond;
inline constexpr struct are final : named_unit<"a", square(si::deca<si::metre>)> {} are; constexpr struct are final : named_unit<"a", square(si::deca<si::metre>)> {} are;
inline constexpr auto hectare = si::hecto<are>; constexpr auto hectare = si::hecto<are>;
inline constexpr struct litre final : named_unit<"l", cubic(si::deci<si::metre>)> {} litre; constexpr struct litre final : named_unit<"l", cubic(si::deci<si::metre>)> {} litre;
inline constexpr struct tonne final : named_unit<"t", mag<1000> * si::kilogram> {} tonne; constexpr struct tonne final : named_unit<"t", mag<1000> * si::kilogram> {} tonne;
inline constexpr struct dalton final : named_unit<"Da", mag_ratio<16'605'390'666'050, 10'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} dalton; constexpr struct dalton final : named_unit<"Da", mag_ratio<16'605'390'666'050, 10'000'000'000'000> * mag_power<10, -27> * si::kilogram> {} dalton;
// TODO A different value is provided in the SI Brochure and different in the ISO 80000 // TODO A different value is provided in the SI Brochure and different in the ISO 80000
inline constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt; constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt;
// TODO the below are logarithmic units - how to support those? // TODO the below are logarithmic units - how to support those?
// neper // neper
// bel // bel
@@ -126,10 +126,10 @@ using namespace non_si;
} // namespace si } // namespace si
template<> template<>
inline constexpr bool space_before_unit_symbol<non_si::degree> = false; constexpr bool space_before_unit_symbol<non_si::degree> = false;
template<> template<>
inline constexpr bool space_before_unit_symbol<non_si::arcminute> = false; constexpr bool space_before_unit_symbol<non_si::arcminute> = false;
template<> template<>
inline constexpr bool space_before_unit_symbol<non_si::arcsecond> = false; constexpr bool space_before_unit_symbol<non_si::arcsecond> = false;
} // namespace mp_units } // namespace mp_units

View File

@@ -36,11 +36,11 @@ namespace mp_units::typographic {
// clang-format off // clang-format off
// https://en.wikipedia.org/wiki/Point_(typography) // https://en.wikipedia.org/wiki/Point_(typography)
inline constexpr struct pica_us final : named_unit<"pica(us)", mag_ratio<166'044, 1'000'000> * international::inch> {} pica_us; constexpr struct pica_us final : named_unit<"pica(us)", mag_ratio<166'044, 1'000'000> * international::inch> {} pica_us;
inline constexpr struct point_us final : named_unit<"point(us)", mag_ratio<1, 12> * pica_us> {} point_us; constexpr struct point_us final : named_unit<"point(us)", mag_ratio<1, 12> * pica_us> {} point_us;
inline constexpr struct point_dtp final : named_unit<"point(dtp)", mag_ratio<1, 72> * international::inch> {} point_dtp; constexpr struct point_dtp final : named_unit<"point(dtp)", mag_ratio<1, 72> * international::inch> {} point_dtp;
inline constexpr struct pica_dtp final : named_unit<"pica(dtp)", mag<12> * point_dtp> {} pica_dtp; constexpr struct pica_dtp final : named_unit<"pica(dtp)", mag<12> * point_dtp> {} pica_dtp;
// clang-format on // clang-format on
} // namespace mp_units::typographic } // namespace mp_units::typographic

View File

@@ -41,78 +41,78 @@ using namespace international;
// https://en.wikipedia.org/wiki/United_States_customary_units#Length // https://en.wikipedia.org/wiki/United_States_customary_units#Length
// nautical // nautical
inline constexpr struct fathom final : named_unit<"ftm(us)", mag<2> * yard> {} fathom; constexpr struct fathom final : named_unit<"ftm(us)", mag<2> * yard> {} fathom;
inline constexpr struct cable final : named_unit<"cb(us)", mag<120> * fathom> {} cable; constexpr struct cable final : named_unit<"cb(us)", mag<120> * fathom> {} cable;
// survey // survey
struct us_survey_foot final : named_unit<"ft(us)", mag_ratio<1'200, 3'937> * si::metre> {}; struct us_survey_foot final : named_unit<"ft(us)", mag_ratio<1'200, 3'937> * si::metre> {};
struct us_survey_mile final : named_unit<"mi(us)", mag<5280> * us_survey_foot{}> {}; struct us_survey_mile final : named_unit<"mi(us)", mag<5280> * us_survey_foot{}> {};
[[deprecated("In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is deprecated.")]] [[deprecated("In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is deprecated.")]]
inline constexpr us_survey_foot us_survey_foot; constexpr us_survey_foot us_survey_foot;
[[deprecated("In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is deprecated.")]] [[deprecated("In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is deprecated.")]]
inline constexpr us_survey_mile us_survey_mile; constexpr us_survey_mile us_survey_mile;
inline constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * foot> {} link; constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * foot> {} link;
inline constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod; constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
inline constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain; constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
inline constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong; constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
// clang-format on // clang-format on
namespace survey1893 { namespace survey1893 {
// clang-format off // clang-format off
inline constexpr struct us_survey_foot final : named_unit<"ft(us)", mag_ratio<1'200, 3'937> * si::metre> {} us_survey_foot; constexpr struct us_survey_foot final : named_unit<"ft(us)", mag_ratio<1'200, 3'937> * si::metre> {} us_survey_foot;
inline constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * us_survey_foot> {} link; constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * us_survey_foot> {} link;
inline constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod; constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
inline constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain; constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
inline constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong; constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
inline constexpr struct us_survey_mile final : named_unit<"mi(us)", mag<8> * furlong> {} us_survey_mile; constexpr struct us_survey_mile final : named_unit<"mi(us)", mag<8> * furlong> {} us_survey_mile;
inline constexpr struct league final : named_unit<"lea", mag<3> * us_survey_mile> {} league; constexpr struct league final : named_unit<"lea", mag<3> * us_survey_mile> {} league;
// clang-format on // clang-format on
} // namespace survey1893 } // namespace survey1893
// clang-format off // clang-format off
// https://en.wikipedia.org/wiki/United_States_customary_units#Area // https://en.wikipedia.org/wiki/United_States_customary_units#Area
inline constexpr struct acre final : named_unit<"acre", mag<10> * square(survey1893::chain)> {} acre; constexpr struct acre final : named_unit<"acre", mag<10> * square(survey1893::chain)> {} acre;
inline constexpr struct section final : named_unit<"section", mag<640> * acre> {} section; constexpr struct section final : named_unit<"section", mag<640> * acre> {} section;
// https://en.wikipedia.org/wiki/United_States_customary_units#Fluid_volume // https://en.wikipedia.org/wiki/United_States_customary_units#Fluid_volume
inline constexpr struct gallon final : named_unit<"gal", mag<231> * cubic(inch)> {} gallon; constexpr struct gallon final : named_unit<"gal", mag<231> * cubic(inch)> {} gallon;
inline constexpr struct pottle final : named_unit<"pot", mag_ratio<1, 2> * gallon> {} pottle; constexpr struct pottle final : named_unit<"pot", mag_ratio<1, 2> * gallon> {} pottle;
inline constexpr struct quart final : named_unit<"qt", mag_ratio<1, 2> * pottle> {} quart; constexpr struct quart final : named_unit<"qt", mag_ratio<1, 2> * pottle> {} quart;
inline constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint; constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint;
inline constexpr struct cup final : named_unit<"c", mag_ratio<1, 2> * pint> {} cup; constexpr struct cup final : named_unit<"c", mag_ratio<1, 2> * pint> {} cup;
inline constexpr struct gill final : named_unit<"gi", mag_ratio<1, 2> * cup> {} gill; constexpr struct gill final : named_unit<"gi", mag_ratio<1, 2> * cup> {} gill;
inline constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 4> * gill> {} fluid_ounce; constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 4> * gill> {} fluid_ounce;
inline constexpr struct tablespoon final : named_unit<"tbsp", mag_ratio<1, 2> * fluid_ounce> {} tablespoon; constexpr struct tablespoon final : named_unit<"tbsp", mag_ratio<1, 2> * fluid_ounce> {} tablespoon;
inline constexpr struct shot final : named_unit<"jig", mag<3> * tablespoon> {} shot; constexpr struct shot final : named_unit<"jig", mag<3> * tablespoon> {} shot;
inline constexpr struct teaspoon final : named_unit<"tsp", mag_ratio<1, 3> * tablespoon> {} teaspoon; constexpr struct teaspoon final : named_unit<"tsp", mag_ratio<1, 3> * tablespoon> {} teaspoon;
inline constexpr struct minim final : named_unit<"min", mag_ratio<1, 80> * teaspoon> {} minim; constexpr struct minim final : named_unit<"min", mag_ratio<1, 80> * teaspoon> {} minim;
inline constexpr struct fluid_dram final : named_unit<"fl dr", mag<60> * minim> {} fluid_dram; constexpr struct fluid_dram final : named_unit<"fl dr", mag<60> * minim> {} fluid_dram;
inline constexpr struct barrel final : named_unit<"bbl", mag_ratio<315, 10> * gallon> {} barrel; constexpr struct barrel final : named_unit<"bbl", mag_ratio<315, 10> * gallon> {} barrel;
inline constexpr struct oil_barrel final : named_unit<"bbl", mag_ratio<4, 3> * barrel> {} oil_barrel; constexpr struct oil_barrel final : named_unit<"bbl", mag_ratio<4, 3> * barrel> {} oil_barrel;
inline constexpr struct hogshead final : named_unit<"hogshead", mag<63> * gallon> {} hogshead; constexpr struct hogshead final : named_unit<"hogshead", mag<63> * gallon> {} hogshead;
// https://en.wikipedia.org/wiki/United_States_customary_units#Dry_volume // https://en.wikipedia.org/wiki/United_States_customary_units#Dry_volume
inline constexpr struct dry_barrel final : named_unit<"bbl", mag<7056> * cubic(inch)> {} dry_barrel; constexpr struct dry_barrel final : named_unit<"bbl", mag<7056> * cubic(inch)> {} dry_barrel;
inline constexpr struct bushel final : named_unit<"bu", mag_ratio<3'523'907'016'688, 100'000'000'000> * si::litre> {} bushel; constexpr struct bushel final : named_unit<"bu", mag_ratio<3'523'907'016'688, 100'000'000'000> * si::litre> {} bushel;
inline constexpr struct peck final : named_unit<"pk", mag_ratio<1, 4> * bushel> {} peck; constexpr struct peck final : named_unit<"pk", mag_ratio<1, 4> * bushel> {} peck;
inline constexpr struct dry_gallon final : named_unit<"gal", mag_ratio<1, 2> * peck> {} dry_gallon; constexpr struct dry_gallon final : named_unit<"gal", mag_ratio<1, 2> * peck> {} dry_gallon;
inline constexpr struct dry_quart final : named_unit<"qt", mag_ratio<1, 4> * dry_gallon> {} dry_quart; constexpr struct dry_quart final : named_unit<"qt", mag_ratio<1, 4> * dry_gallon> {} dry_quart;
inline constexpr struct dry_pint final : named_unit<"pt", mag_ratio<1, 2> * dry_quart> {} dry_pint; constexpr struct dry_pint final : named_unit<"pt", mag_ratio<1, 2> * dry_quart> {} dry_pint;
// https://en.wikipedia.org/wiki/United_States_customary_units#Mass_and_Weight // https://en.wikipedia.org/wiki/United_States_customary_units#Mass_and_Weight
// https://en.wikipedia.org/wiki/Avoirdupois_system#American_customary_system // https://en.wikipedia.org/wiki/Avoirdupois_system#American_customary_system
inline constexpr struct quarter final : named_unit<"qr", mag<25> * pound> {} quarter; constexpr struct quarter final : named_unit<"qr", mag<25> * pound> {} quarter;
inline constexpr struct short_hundredweight final : named_unit<"cwt", mag<100> * pound> {} short_hundredweight; constexpr struct short_hundredweight final : named_unit<"cwt", mag<100> * pound> {} short_hundredweight;
inline constexpr struct ton final : named_unit<"t", mag<2'000> * pound> {} ton; constexpr struct ton final : named_unit<"t", mag<2'000> * pound> {} ton;
inline constexpr auto short_ton = ton; constexpr auto short_ton = ton;
inline constexpr struct pennyweight final : named_unit<"dwt", mag<24> * grain> {} pennyweight; constexpr struct pennyweight final : named_unit<"dwt", mag<24> * grain> {} pennyweight;
inline constexpr struct troy_once final : named_unit<"oz t", mag<20> * pennyweight> {} troy_once; constexpr struct troy_once final : named_unit<"oz t", mag<20> * pennyweight> {} troy_once;
inline constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_once> {} troy_pound; constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_once> {} troy_pound;
// https://en.wikipedia.org/wiki/Inch_of_mercury // https://en.wikipedia.org/wiki/Inch_of_mercury
#ifdef pascal #ifdef pascal
@@ -120,15 +120,15 @@ inline constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_onc
#undef pascal #undef pascal
#define MP_UNITS_REDEFINE_PASCAL #define MP_UNITS_REDEFINE_PASCAL
#endif #endif
inline constexpr struct inch_of_mercury final : named_unit<"inHg", mag_ratio<3'386'389, 1'000> * si::pascal> {} inch_of_mercury; constexpr struct inch_of_mercury final : named_unit<"inHg", mag_ratio<3'386'389, 1'000> * si::pascal> {} inch_of_mercury;
#ifdef MP_UNITS_REDEFINE_PASCAL #ifdef MP_UNITS_REDEFINE_PASCAL
#pragma pop_macro("pascal") #pragma pop_macro("pascal")
#undef MP_UNITS_REDEFINE_PASCAL #undef MP_UNITS_REDEFINE_PASCAL
#endif #endif
// https://en.wikipedia.org/wiki/United_States_customary_units#Temperature // https://en.wikipedia.org/wiki/United_States_customary_units#Temperature
inline constexpr struct zeroth_degree_Fahrenheit final : relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_degree_Fahrenheit; constexpr struct zeroth_degree_Fahrenheit final : relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_degree_Fahrenheit;
inline constexpr struct degree_Fahrenheit final : named_unit<symbol_text{u8"", "`F"}, mag_ratio<5, 9> * si::degree_Celsius, zeroth_degree_Fahrenheit> {} degree_Fahrenheit; constexpr struct degree_Fahrenheit final : named_unit<symbol_text{u8"", "`F"}, mag_ratio<5, 9> * si::degree_Celsius, zeroth_degree_Fahrenheit> {} degree_Fahrenheit;
// clang-format on // clang-format on
@@ -136,51 +136,51 @@ namespace unit_symbols {
using namespace international::unit_symbols; using namespace international::unit_symbols;
inline constexpr auto ftm = fathom; constexpr auto ftm = fathom;
inline constexpr auto cb = cable; constexpr auto cb = cable;
[[deprecated( [[deprecated(
"In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is " "In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is "
"deprecated.")]] inline constexpr struct us_survey_foot us_ft; "deprecated.")]] constexpr struct us_survey_foot us_ft;
[[deprecated( [[deprecated(
"In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is " "In accordance with NIST SP 811, as of January 1, 2023, the use of the U.S. survey foot and U.S. survey mile is "
"deprecated.")]] inline constexpr struct us_survey_mile us_mi; "deprecated.")]] constexpr struct us_survey_mile us_mi;
inline constexpr auto li = link; constexpr auto li = link;
inline constexpr auto rd = rod; constexpr auto rd = rod;
inline constexpr auto ch = chain; constexpr auto ch = chain;
inline constexpr auto fur = furlong; constexpr auto fur = furlong;
inline constexpr auto lea = league; constexpr auto lea = league;
inline constexpr auto gal = gallon; constexpr auto gal = gallon;
inline constexpr auto pot = pottle; constexpr auto pot = pottle;
inline constexpr auto qt = quart; constexpr auto qt = quart;
inline constexpr auto pt = pint; constexpr auto pt = pint;
inline constexpr auto c = cup; constexpr auto c = cup;
inline constexpr auto gi = gill; constexpr auto gi = gill;
inline constexpr auto fl_oz = fluid_ounce; constexpr auto fl_oz = fluid_ounce;
inline constexpr auto tbsp = tablespoon; constexpr auto tbsp = tablespoon;
inline constexpr auto jig = shot; constexpr auto jig = shot;
inline constexpr auto tsp = teaspoon; constexpr auto tsp = teaspoon;
inline constexpr auto min = minim; constexpr auto min = minim;
inline constexpr auto fl_dr = fluid_dram; constexpr auto fl_dr = fluid_dram;
inline constexpr auto bbl = barrel; constexpr auto bbl = barrel;
inline constexpr auto dry_bbl = dry_barrel; constexpr auto dry_bbl = dry_barrel;
inline constexpr auto bu = bushel; constexpr auto bu = bushel;
inline constexpr auto pk = peck; constexpr auto pk = peck;
inline constexpr auto dry_gal = dry_gallon; constexpr auto dry_gal = dry_gallon;
inline constexpr auto dry_qt = dry_quart; constexpr auto dry_qt = dry_quart;
inline constexpr auto dry_pt = dry_pint; constexpr auto dry_pt = dry_pint;
inline constexpr auto qr = quarter; constexpr auto qr = quarter;
inline constexpr auto cwt = short_hundredweight; constexpr auto cwt = short_hundredweight;
inline constexpr auto t = ton; constexpr auto t = ton;
inline constexpr auto dwt = pennyweight; constexpr auto dwt = pennyweight;
inline constexpr auto oz_t = troy_once; constexpr auto oz_t = troy_once;
inline constexpr auto lb_t = troy_pound; constexpr auto lb_t = troy_pound;
inline constexpr auto inHg = inch_of_mercury; constexpr auto inHg = inch_of_mercury;
inline constexpr auto deg_F = degree_Fahrenheit; constexpr auto deg_F = degree_Fahrenheit;
} // namespace unit_symbols } // namespace unit_symbols

View File

@@ -50,7 +50,7 @@ import mp_units;
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
using namespace mp_units; using namespace mp_units;
using namespace mp_units::si::unit_symbols; using namespace mp_units::si::unit_symbols;

View File

@@ -44,10 +44,10 @@ template<typename Rep = double>
using vector = STD_LA::fixed_size_column_vector<Rep, 3>; using vector = STD_LA::fixed_size_column_vector<Rep, 3>;
template<class Rep> template<class Rep>
inline constexpr bool mp_units::treat_as_floating_point<vector<Rep>> = mp_units::treat_as_floating_point<Rep>; constexpr bool mp_units::treat_as_floating_point<vector<Rep>> = mp_units::treat_as_floating_point<Rep>;
template<typename Rep> template<typename Rep>
inline constexpr bool mp_units::is_vector<vector<Rep>> = true; constexpr bool mp_units::is_vector<vector<Rep>> = true;
template<typename Rep> template<typename Rep>
std::ostream& operator<<(std::ostream& os, const vector<Rep>& v) std::ostream& operator<<(std::ostream& os, const vector<Rep>& v)
@@ -301,7 +301,7 @@ TEST_CASE("vector quantity", "[la]")
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
TEST_CASE("vector of quantities", "[la]") TEST_CASE("vector of quantities", "[la]")
{ {

View File

@@ -42,9 +42,9 @@ using namespace mp_units;
using namespace mp_units::angular; using namespace mp_units::angular;
using namespace mp_units::angular::unit_symbols; using namespace mp_units::angular::unit_symbols;
inline constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> { constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> {
} half_revolution; } half_revolution;
inline constexpr auto hrev = half_revolution; constexpr auto hrev = half_revolution;
// constexpr auto revb6 = mag_ratio<1,3> * mag_pi * rad; // constexpr auto revb6 = mag_ratio<1,3> * mag_pi * rad;

View File

@@ -28,7 +28,7 @@
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {

View File

@@ -37,19 +37,19 @@ import std;
#if MP_UNITS_HOSTED #if MP_UNITS_HOSTED
template<typename T> template<typename T>
inline constexpr bool mp_units::is_scalar<std::complex<T>> = true; constexpr bool mp_units::is_scalar<std::complex<T>> = true;
#endif #endif
namespace { namespace {
using namespace mp_units; using namespace mp_units;
inline constexpr struct my_origin final : absolute_point_origin<isq::length> { constexpr struct my_origin final : absolute_point_origin<isq::length> {
} my_origin; } my_origin;
inline constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> { constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> {
} my_relative_origin; } my_relative_origin;
inline constexpr auto dim_speed = isq::dim_length / isq::dim_time; constexpr auto dim_speed = isq::dim_length / isq::dim_time;
// BaseDimension // BaseDimension
static_assert(detail::BaseDimension<struct isq::dim_length>); static_assert(detail::BaseDimension<struct isq::dim_length>);
@@ -78,7 +78,7 @@ static_assert(!Dimension<int>);
// TODO add tests // TODO add tests
// QuantitySpec // QuantitySpec
inline constexpr auto speed = isq::length / isq::time; constexpr auto speed = isq::length / isq::time;
static_assert(QuantitySpec<struct isq::length>); static_assert(QuantitySpec<struct isq::length>);
static_assert(QuantitySpec<struct isq::radius>); static_assert(QuantitySpec<struct isq::radius>);

View File

@@ -61,7 +61,7 @@ public:
} // namespace } // namespace
template<typename T> template<typename T>
inline constexpr bool mp_units::is_scalar<min_impl<T>> = true; constexpr bool mp_units::is_scalar<min_impl<T>> = true;
template<typename T, typename U> template<typename T, typename U>
struct std::common_type<min_impl<T>, min_impl<U>> : std::type_identity<min_impl<std::common_type_t<T, U>>> {}; struct std::common_type<min_impl<T>, min_impl<U>> : std::type_identity<min_impl<std::common_type_t<T, U>>> {};

View File

@@ -36,31 +36,31 @@ using namespace mp_units;
using dimension_one_ = struct dimension_one; using dimension_one_ = struct dimension_one;
// clang-format off // clang-format off
inline constexpr struct length_ final : base_dimension<"L"> {} length; constexpr struct length_ final : base_dimension<"L"> {} length;
inline constexpr struct mass_ final : base_dimension<"M"> {} mass; constexpr struct mass_ final : base_dimension<"M"> {} mass;
inline constexpr struct time_ final : base_dimension<"T"> {} time; constexpr struct time_ final : base_dimension<"T"> {} time;
inline constexpr auto my_length1 = length; constexpr auto my_length1 = length;
inline constexpr auto my_length2 = length; constexpr auto my_length2 = length;
QUANTITY_SPEC_(q_time, time); QUANTITY_SPEC_(q_time, time);
inline constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second; constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second;
inline constexpr auto frequency = inverse(time); constexpr auto frequency = inverse(time);
inline constexpr auto action = inverse(time); constexpr auto action = inverse(time);
inline constexpr auto area = length * length; constexpr auto area = length * length;
inline constexpr auto volume = area * length; constexpr auto volume = area * length;
inline constexpr auto speed = length / time; constexpr auto speed = length / time;
inline constexpr auto acceleration = speed / time; constexpr auto acceleration = speed / time;
inline constexpr auto force = mass * acceleration; constexpr auto force = mass * acceleration;
inline constexpr auto moment_of_force = length * force; constexpr auto moment_of_force = length * force;
inline constexpr auto torque = moment_of_force; constexpr auto torque = moment_of_force;
inline constexpr auto pressure = force / area; constexpr auto pressure = force / area;
inline constexpr auto stress = pressure; constexpr auto stress = pressure;
inline constexpr auto strain = stress / stress; constexpr auto strain = stress / stress;
inline constexpr auto power = force * speed; constexpr auto power = force * speed;
inline constexpr auto efficiency = power / power; constexpr auto efficiency = power / power;
inline constexpr auto energy = force * length; constexpr auto energy = force * length;
// clang-format on // clang-format on
// concepts verification // concepts verification

View File

@@ -26,7 +26,7 @@
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {

View File

@@ -28,7 +28,7 @@
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {

View File

@@ -32,7 +32,7 @@ using namespace units;
using namespace units::detail; using namespace units::detail;
template<> template<>
inline constexpr std::optional<std::intmax_t> units::known_first_factor<9223372036854775783> = 9223372036854775783; constexpr std::optional<std::intmax_t> units::known_first_factor<9223372036854775783> = 9223372036854775783;
namespace { namespace {
@@ -71,11 +71,11 @@ namespace {
// CHECK(round_trip == R); // CHECK(round_trip == R);
// } // }
inline constexpr struct mag_2_ : magnitude<2> { constexpr struct mag_2_ : magnitude<2> {
} mag_2; } mag_2;
// inline constexpr struct mag_2_other : magnitude<2> { // constexpr struct mag_2_other : magnitude<2> {
// } mag_2_other; // } mag_2_other;
// inline constexpr struct mag_3 : magnitude<2> { // constexpr struct mag_3 : magnitude<2> {
// } mag_3; // } mag_3;
// concepts verification // concepts verification

View File

@@ -24,7 +24,7 @@
template<class T> template<class T>
requires mp_units::is_scalar<T> requires mp_units::is_scalar<T>
inline constexpr bool mp_units::is_vector<T> = true; constexpr bool mp_units::is_vector<T> = true;
namespace { namespace {

View File

@@ -50,38 +50,38 @@ using namespace std::chrono_literals;
using sys_seconds = std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>; using sys_seconds = std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>;
#endif #endif
inline constexpr struct zeroth_length final : absolute_point_origin<isq::length> { constexpr struct zeroth_length final : absolute_point_origin<isq::length> {
} zeroth_length; } zeroth_length;
inline constexpr struct mean_sea_level final : absolute_point_origin<isq::height> { constexpr struct mean_sea_level final : absolute_point_origin<isq::height> {
} mean_sea_level; } mean_sea_level;
inline constexpr auto my_mean_sea_level = mean_sea_level; constexpr auto my_mean_sea_level = mean_sea_level;
inline constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> { constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> {
} same_mean_sea_level; } same_mean_sea_level;
inline constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> { constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
} ground_level; } ground_level;
inline constexpr auto my_ground_level = ground_level; constexpr auto my_ground_level = ground_level;
inline constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> { constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
} same_ground_level1; } same_ground_level1;
inline constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> { constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> {
} same_ground_level2; } same_ground_level2;
inline constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> { constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> {
} tower_peak; } tower_peak;
inline constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> { constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> {
} other_ground_level; } other_ground_level;
inline constexpr struct other_absolute_level final : absolute_point_origin<isq::height> { constexpr struct other_absolute_level final : absolute_point_origin<isq::height> {
} other_absolute_level; } other_absolute_level;
inline constexpr struct zero final : absolute_point_origin<dimensionless> { constexpr struct zero final : absolute_point_origin<dimensionless> {
} zero; } zero;
QUANTITY_SPEC(special_height, isq::height); QUANTITY_SPEC(special_height, isq::height);
@@ -111,18 +111,18 @@ static_assert(ground_level != other_ground_level);
template<auto QS> template<auto QS>
struct absolute_po_ final : absolute_point_origin<QS> {}; struct absolute_po_ final : absolute_point_origin<QS> {};
template<auto QS> template<auto QS>
inline constexpr absolute_po_<QS> absolute_po; constexpr absolute_po_<QS> absolute_po;
template<auto QP> template<auto QP>
struct relative_po_ final : relative_point_origin<QP> {}; struct relative_po_ final : relative_point_origin<QP> {};
template<auto QP> template<auto QP>
inline constexpr relative_po_<QP> relative_po; constexpr relative_po_<QP> relative_po;
static_assert(relative_po<absolute_po<isq::length> + isq::height(42 * m)>.quantity_spec == isq::height); static_assert(relative_po<absolute_po<isq::length> + isq::height(42 * m)>.quantity_spec == isq::height);
static_assert(relative_po<absolute_po<kind_of<isq::length>> + isq::height(42 * m)>.quantity_spec == isq::height); static_assert(relative_po<absolute_po<kind_of<isq::length>> + isq::height(42 * m)>.quantity_spec == isq::height);
static_assert(relative_po<absolute_po<isq::height> + 42 * m>.quantity_spec == isq::height); static_assert(relative_po<absolute_po<isq::height> + 42 * m>.quantity_spec == isq::height);
inline constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> { constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> {
} my_kelvin; } my_kelvin;
static_assert(default_point_origin(si::kelvin) == si::absolute_zero); static_assert(default_point_origin(si::kelvin) == si::absolute_zero);
@@ -1516,7 +1516,7 @@ static_assert(ground_level - other_ground_level == -81 * m);
static_assert(other_ground_level - tower_peak == 39 * m); static_assert(other_ground_level - tower_peak == 39 * m);
static_assert(tower_peak - other_ground_level == -39 * m); static_assert(tower_peak - other_ground_level == -39 * m);
inline constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> { constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> {
} zero_m_per_s; } zero_m_per_s;
// commutativity and associativity // commutativity and associativity
@@ -1604,7 +1604,7 @@ static_assert(
is_of_type<quantity_point{10 * isq::height[m] / (2 * isq::time[s])} + (10 * isq::height[m] / (2 * isq::time[s])), is_of_type<quantity_point{10 * isq::height[m] / (2 * isq::time[s])} + (10 * isq::height[m] / (2 * isq::time[s])),
quantity_point<(isq::height / isq::time)[m / s], zeroth_point_origin<isq::height / isq::time>, int>>); quantity_point<(isq::height / isq::time)[m / s], zeroth_point_origin<isq::height / isq::time>, int>>);
inline constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> { constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> {
} zero_Hz; } zero_Hz;
static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) + 5 * isq::frequency[Hz]).quantity_from(zero_Hz) == static_assert(((zero_Hz + 10 / (2 * isq::period_duration[s])) + 5 * isq::frequency[Hz]).quantity_from(zero_Hz) ==
@@ -1688,7 +1688,7 @@ consteval bool invalid_subtraction(Ts... ts)
return !requires { (... - ts); }; return !requires { (... - ts); };
} }
inline constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> { constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> {
} zero_Bq; } zero_Bq;
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz])); static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));

View File

@@ -37,22 +37,22 @@ using dimensionless_ = struct dimensionless;
using dim_one_ = struct dimension_one; using dim_one_ = struct dimension_one;
// clang-format off // clang-format off
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length; constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass; constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time; constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
// quantities specification // quantities specification
QUANTITY_SPEC_(length, dim_length); QUANTITY_SPEC_(length, dim_length);
QUANTITY_SPEC_(mass, dim_mass); QUANTITY_SPEC_(mass, dim_mass);
QUANTITY_SPEC_(time, dim_time); QUANTITY_SPEC_(time, dim_time);
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second; constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
QUANTITY_SPEC_(height, length); QUANTITY_SPEC_(height, length);
QUANTITY_SPEC_(width, length); QUANTITY_SPEC_(width, length);
QUANTITY_SPEC_(radius, width); QUANTITY_SPEC_(radius, width);
QUANTITY_SPEC_(path_length, length); QUANTITY_SPEC_(path_length, length);
inline constexpr auto arc_length = path_length; constexpr auto arc_length = path_length;
QUANTITY_SPEC_(distance, path_length); QUANTITY_SPEC_(distance, path_length);
QUANTITY_SPEC_(position_vector, length, quantity_character::vector); QUANTITY_SPEC_(position_vector, length, quantity_character::vector);
QUANTITY_SPEC_(period_duration, time); QUANTITY_SPEC_(period_duration, time);

View File

@@ -41,7 +41,7 @@ import std;
#endif #endif
template<> template<>
inline constexpr bool mp_units::is_vector<int> = true; constexpr bool mp_units::is_vector<int> = true;
namespace { namespace {
@@ -901,7 +901,7 @@ static_assert(1 * si::si2019::speed_of_light_in_vacuum == 299'792'458 * isq::spe
// Different named dimensions // Different named dimensions
template<Reference auto R1, Reference auto R2> template<Reference auto R1, Reference auto R2>
inline constexpr bool invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; }; constexpr bool invalid_comparison = !requires { 2 * R1 == 2 * R2; } && !requires { 2 * R2 == 2 * R1; };
static_assert(invalid_comparison<isq::activity[Bq], isq::frequency[Hz]>); static_assert(invalid_comparison<isq::activity[Bq], isq::frequency[Hz]>);

View File

@@ -39,9 +39,9 @@ using one_ = struct one;
// base dimensions // base dimensions
// clang-format off // clang-format off
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length; constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass; constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time; constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
// quantities specification // quantities specification
QUANTITY_SPEC_(length, dim_length); QUANTITY_SPEC_(length, dim_length);
@@ -64,37 +64,37 @@ QUANTITY_SPEC_(power, force* speed);
QUANTITY_SPEC_(storage_capacity, dimensionless, is_kind); QUANTITY_SPEC_(storage_capacity, dimensionless, is_kind);
// base units // base units
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second; constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre; constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram; constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
inline constexpr auto kilogram = si::kilo<gram>; constexpr auto kilogram = si::kilo<gram>;
namespace nu { namespace nu {
// hypothetical natural system of units for c=1 // hypothetical natural system of units for c=1
inline constexpr struct second_ final : named_unit<"s"> {} second; constexpr struct second_ final : named_unit<"s"> {} second;
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute; constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
inline constexpr struct time : system_reference<time_{}, second> {} time; constexpr struct time : system_reference<time_{}, second> {} time;
inline constexpr struct length : system_reference<length_{}, second> {} length; constexpr struct length : system_reference<length_{}, second> {} length;
inline constexpr struct speed : system_reference<speed_{}, second / second> {} speed; constexpr struct speed : system_reference<speed_{}, second / second> {} speed;
} }
// derived named units // derived named units
inline constexpr struct radian_ final : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian; constexpr struct radian_ final : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian;
inline constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian; constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian;
inline constexpr struct hertz_ final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz; constexpr struct hertz_ final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
inline constexpr struct becquerel_ final : named_unit<"Bq", inverse(second), kind_of<activity>> {} becquerel; constexpr struct becquerel_ final : named_unit<"Bq", inverse(second), kind_of<activity>> {} becquerel;
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule; constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt; constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute; constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour; constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
inline constexpr auto kilometre = si::kilo<metre>; constexpr auto kilometre = si::kilo<metre>;
inline constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit; constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
// clang-format on // clang-format on

View File

@@ -31,19 +31,19 @@ import std;
#endif #endif
template<auto V, typename T> template<auto V, typename T>
inline constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>; constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T>;
// NOLINTBEGIN(cppcoreguidelines-macro-usage) // NOLINTBEGIN(cppcoreguidelines-macro-usage)
#if MP_UNITS_API_NO_CRTP #if MP_UNITS_API_NO_CRTP
#define QUANTITY_SPEC_(name, ...) \ #define QUANTITY_SPEC_(name, ...) \
inline constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \ constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
} name } name
#else #else
#define QUANTITY_SPEC_(name, ...) \ #define QUANTITY_SPEC_(name, ...) \
inline constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \ constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \
} name } name
#endif #endif

View File

@@ -40,10 +40,10 @@ using percent_ = struct percent;
// base dimensions // base dimensions
// clang-format off // clang-format off
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length; constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass; constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time; constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
inline constexpr struct dim_thermodynamic_temperature_ final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature; constexpr struct dim_thermodynamic_temperature_ final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
// quantities specification // quantities specification
QUANTITY_SPEC_(length, dim_length); QUANTITY_SPEC_(length, dim_length);
@@ -52,39 +52,39 @@ QUANTITY_SPEC_(time, dim_time);
QUANTITY_SPEC_(thermodynamic_temperature, dim_thermodynamic_temperature); QUANTITY_SPEC_(thermodynamic_temperature, dim_thermodynamic_temperature);
// base units // base units
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second; constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre; constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram; constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
inline constexpr auto kilogram = si::kilo<gram>; constexpr auto kilogram = si::kilo<gram>;
inline constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin; constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin;
// hypothetical natural units for c=1 // hypothetical natural units for c=1
inline constexpr struct nu_second_ final : named_unit<"s"> {} nu_second; constexpr struct nu_second_ final : named_unit<"s"> {} nu_second;
// derived named units // derived named units
inline constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian; constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian;
inline constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian; constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian;
inline constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz; constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz;
inline constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel; constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel;
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton; constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal; constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule; constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt; constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
inline constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"", "`C"}, kelvin> {} degree_Celsius; constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"", "`C"}, kelvin> {} degree_Celsius;
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute; constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour; constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
inline constexpr struct degree_ final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * radian> {} degree; constexpr struct degree_ final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * radian> {} degree;
inline constexpr struct yard_ final : named_unit<"yd", mag_ratio<9'144, 10'000> * metre> {} yard; constexpr struct yard_ final : named_unit<"yd", mag_ratio<9'144, 10'000> * metre> {} yard;
inline constexpr struct mile_ final : named_unit<"mi", mag<1760> * yard> {} mile; constexpr struct mile_ final : named_unit<"mi", mag<1760> * yard> {} mile;
inline constexpr auto kilometre = si::kilo<metre>; constexpr auto kilometre = si::kilo<metre>;
inline constexpr auto kilojoule = si::kilo<joule>; constexpr auto kilojoule = si::kilo<joule>;
// physical constant units // physical constant units
inline constexpr struct standard_gravity_ final : named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity; constexpr struct standard_gravity_ final : named_unit<symbol_text{u8"g₀", "g_0"}, mag_ratio<980'665, 100'000> * metre / square(second)> {} standard_gravity;
inline constexpr struct speed_of_light_in_vacuum_ final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; constexpr struct speed_of_light_in_vacuum_ final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
// clang-format on // clang-format on