mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
fix: inline
restored for non-template constexpr
global variables
This commit is contained in:
@ -49,19 +49,19 @@ As a side effect, we introduced a :boom: **breaking change** :boom:. We can't us
|
||||
hertz anymore:
|
||||
|
||||
```cpp
|
||||
constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
|
||||
inline constexpr struct hertz : named_unit<"Hz", 1 / second, kind_of<isq::frequency>> {} hertz;
|
||||
```
|
||||
|
||||
and have to type either:
|
||||
|
||||
```cpp
|
||||
constexpr struct hertz : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
|
||||
inline constexpr struct hertz : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```cpp
|
||||
constexpr struct hertz : named_unit<"Hz", inverse(second), kind_of<isq::frequency>> {} hertz;
|
||||
inline 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
|
||||
@ -70,13 +70,13 @@ specifications definitions. Now, to define a _frequency_ we have to type:
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct frequency : quantity_spec<inverse(period_duration)> {} frequency;
|
||||
inline constexpr struct frequency : quantity_spec<inverse(period_duration)> {} frequency;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct frequency : quantity_spec<frequency, inverse(period_duration)> {} frequency;
|
||||
inline constexpr struct frequency : quantity_spec<frequency, inverse(period_duration)> {} frequency;
|
||||
```
|
||||
|
||||
=== "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:
|
||||
|
||||
```cpp
|
||||
constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
|
||||
constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin;
|
||||
inline 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 ice_point : relative_point_origin<absolute_zero + 273.15 * kelvin> {} ice_point;
|
||||
constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
Please note that this is a :boom: **breaking change** :boom: as well.
|
||||
|
@ -281,13 +281,13 @@ is why it was renamed to `symbol_text` (:boom: **breaking change** :boom:).
|
||||
=== "Now"
|
||||
|
||||
```cpp
|
||||
constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
```
|
||||
|
||||
=== "Before"
|
||||
|
||||
```cpp
|
||||
constexpr struct ohm : named_unit<basic_symbol_text{"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct ohm : named_unit<basic_symbol_text{"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
```
|
||||
|
||||
!!! 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:
|
||||
|
||||
```cpp
|
||||
constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
```
|
||||
|
||||
|
||||
@ -307,31 +307,31 @@ marked `final` (:boom: **breaking change** :boom:).
|
||||
=== "Now"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
|
||||
constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
constexpr auto zeroth_kelvin = absolute_zero;
|
||||
constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
inline constexpr auto zeroth_kelvin = absolute_zero;
|
||||
inline constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
|
||||
constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
|
||||
constexpr auto zeroth_degree_Celsius = ice_point;
|
||||
constexpr struct degree_Celsius final : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
|
||||
inline constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "Before"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_length : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct length : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct dim_length : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct length : quantity_spec<dim_length> {} length;
|
||||
|
||||
constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
|
||||
constexpr struct zeroth_kelvin : decltype(absolute_zero) {} zeroth_kelvin;
|
||||
constexpr struct kelvin : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
inline constexpr struct absolute_zero : absolute_point_origin<absolute_zero, isq::thermodynamic_temperature> {} absolute_zero;
|
||||
inline 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 ice_point : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
|
||||
constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius;
|
||||
constexpr struct degree_Celsius : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
|
||||
inline 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;
|
||||
inline 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:).
|
||||
@ -509,13 +509,13 @@ conversion factor. Here is a comparison of the code with previous and current de
|
||||
=== "Now"
|
||||
|
||||
```cpp
|
||||
constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
|
||||
constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "Before"
|
||||
|
||||
```cpp
|
||||
constexpr struct yard : named_unit<"yd", mag<ratio{9'144, 10'000}> * si::metre> {} yard;
|
||||
constexpr struct foot : named_unit<"ft", mag<ratio{1, 3}> * yard> {} foot;
|
||||
inline 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;
|
||||
```
|
||||
|
@ -33,7 +33,7 @@ The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units)
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
|
||||
inline constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
|
||||
|
||||
int main()
|
||||
{
|
||||
@ -53,7 +53,7 @@ The library source code is hosted on [GitHub](https://github.com/mpusz/mp-units)
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
|
||||
inline constexpr struct smoot final : named_unit<"smoot", mag<67> * usc::inch> {} smoot;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -97,15 +97,15 @@ enumeration can be appended to the `quantity_spec` describing such a quantity ty
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
|
||||
constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector;
|
||||
constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "Portable"
|
||||
@ -126,13 +126,13 @@ character override is needed):
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity;
|
||||
inline constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct velocity final : quantity_spec<velocity, speed, position_vector / duration> {} velocity;
|
||||
inline constexpr struct velocity final : quantity_spec<velocity, speed, position_vector / duration> {} velocity;
|
||||
```
|
||||
|
||||
=== "Portable"
|
||||
|
@ -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:
|
||||
|
||||
```cpp
|
||||
constexpr struct mean_sea_level final : absolute_point_origin<isq::altitude> {} mean_sea_level;
|
||||
inline 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
|
||||
|
@ -60,8 +60,8 @@ For example:
|
||||
the following way:
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
```
|
||||
|
||||
[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"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
constexpr struct time final : quantity_spec<dim_time> {} time;
|
||||
constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct time final : quantity_spec<dim_time> {} time;
|
||||
inline constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
|
||||
static_assert(speed.dimension == dim_length / dim_time);
|
||||
```
|
||||
@ -81,9 +81,9 @@ provided in the [quantity specification](../../appendix/glossary.md#quantity_spe
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
constexpr struct time final : quantity_spec<time, dim_time> {} time;
|
||||
constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
|
||||
inline constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
inline constexpr struct time final : quantity_spec<time, dim_time> {} time;
|
||||
inline constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
|
||||
|
||||
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"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
constexpr struct height final : quantity_spec<length> {} height;
|
||||
constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct height final : quantity_spec<length> {} height;
|
||||
inline constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
constexpr struct height final : quantity_spec<height, length> {} height;
|
||||
constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
|
||||
inline constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
inline constexpr struct height final : quantity_spec<height, length> {} height;
|
||||
inline constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
|
||||
```
|
||||
|
||||
=== "Portable"
|
||||
@ -234,13 +234,13 @@ A unit can be defined by the user in one of the following ways:
|
||||
template<PrefixableUnit U> struct kilo_ : prefixed_unit<"k", mag_power<10, 3>, U{}> {};
|
||||
template<PrefixableUnit auto U> constexpr kilo_<decltype(U)> kilo;
|
||||
|
||||
constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
|
||||
constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
constexpr auto kilogram = kilo<gram>;
|
||||
constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
|
||||
inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
inline constexpr auto kilogram = kilo<gram>;
|
||||
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
|
||||
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 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
|
||||
@ -346,13 +346,13 @@ For example:
|
||||
- the absolute point origin can be defined in the following way:
|
||||
|
||||
```cpp
|
||||
constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
```
|
||||
|
||||
- the relative point origin can be defined in the following way:
|
||||
|
||||
```cpp
|
||||
constexpr struct ice_point final : relative_point_origin<absolute_zero + 273'150 * milli<kelvin>> {} ice_point;
|
||||
inline constexpr struct ice_point final : relative_point_origin<absolute_zero + 273'150 * milli<kelvin>> {} ice_point;
|
||||
```
|
||||
|
||||
|
||||
|
@ -113,7 +113,7 @@ that uses a unit that is proportional to the ratio of kilometers per megaparsecs
|
||||
units of _length_:
|
||||
|
||||
```cpp
|
||||
constexpr struct hubble_constant final :
|
||||
inline 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;
|
||||
```
|
||||
|
||||
@ -158,10 +158,10 @@ Besides the unit `one`, there are a few other scaled units predefined in the lib
|
||||
with dimensionless quantities:
|
||||
|
||||
```cpp
|
||||
constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
|
||||
constexpr struct per_mille final : named_unit<{u8"‰", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
|
||||
constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
|
||||
constexpr auto ppm = parts_per_million;
|
||||
inline 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;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
### Superpowers of the unit `one`
|
||||
@ -271,17 +271,17 @@ to the quantity specification:
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure;
|
||||
constexpr struct solid_angular_measure final : quantity_spec<dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure;
|
||||
constexpr struct storage_capacity final : quantity_spec<dimensionless, is_kind> {} storage_capacity;
|
||||
inline 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;
|
||||
inline constexpr struct storage_capacity final : quantity_spec<dimensionless, is_kind> {} storage_capacity;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct angular_measure final : quantity_spec<angular_measure, dimensionless, arc_length / radius, is_kind> {} angular_measure;
|
||||
constexpr struct solid_angular_measure final : quantity_spec<solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind> {} solid_angular_measure;
|
||||
constexpr struct storage_capacity final : quantity_spec<storage_capacity, dimensionless, is_kind> {} storage_capacity;
|
||||
inline 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;
|
||||
inline constexpr struct storage_capacity final : quantity_spec<storage_capacity, dimensionless, is_kind> {} storage_capacity;
|
||||
```
|
||||
|
||||
=== "Portable"
|
||||
@ -296,9 +296,9 @@ With the above, we can constrain `radian`, `steradian`, and `bit` to be allowed
|
||||
specific quantity kinds only:
|
||||
|
||||
```cpp
|
||||
constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
|
||||
constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
|
||||
constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
inline 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;
|
||||
inline 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.
|
||||
|
@ -39,12 +39,12 @@ namespace si {
|
||||
|
||||
namespace si2019 {
|
||||
|
||||
constexpr struct speed_of_light_in_vacuum final :
|
||||
inline constexpr struct speed_of_light_in_vacuum final :
|
||||
named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
|
||||
|
||||
} // namespace si2019
|
||||
|
||||
constexpr struct magnetic_constant final :
|
||||
inline constexpr struct magnetic_constant final :
|
||||
named_unit<{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant;
|
||||
|
||||
} // namespace mp_units::si
|
||||
|
@ -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:
|
||||
|
||||
```cpp
|
||||
constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
|
||||
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;
|
||||
inline 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
|
||||
@ -97,9 +97,9 @@ the value-based [unit equation](../../appendix/glossary.md#unit-equation) to a c
|
||||
definition:
|
||||
|
||||
```cpp
|
||||
constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
```
|
||||
|
||||
|
||||
|
@ -316,12 +316,12 @@ Let's see another example:
|
||||
using namespace mp_units;
|
||||
|
||||
// add a custom quantity type of kind isq::length
|
||||
constexpr struct horizontal_length final :
|
||||
inline constexpr struct horizontal_length final :
|
||||
quantity_spec<isq::length> {} horizontal_length;
|
||||
|
||||
// add a custom derived quantity type of kind isq::area
|
||||
// with a constrained quantity equation
|
||||
constexpr struct horizontal_area final :
|
||||
inline constexpr struct horizontal_area final :
|
||||
quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area;
|
||||
|
||||
class StorageTank {
|
||||
@ -429,12 +429,12 @@ Let's see another example:
|
||||
using namespace mp_units;
|
||||
|
||||
// add a custom quantity type of kind isq::length
|
||||
constexpr struct horizontal_length final :
|
||||
inline constexpr struct horizontal_length final :
|
||||
quantity_spec<isq::length> {} horizontal_length;
|
||||
|
||||
// add a custom derived quantity type of kind isq::area
|
||||
// with a constrained quantity equation
|
||||
constexpr struct horizontal_area final :
|
||||
inline constexpr struct horizontal_area final :
|
||||
quantity_spec<isq::area, horizontal_length * isq::width> {} horizontal_area;
|
||||
|
||||
class StorageTank {
|
||||
|
@ -148,45 +148,45 @@ For example, here is how the above quantity kind tree can be modeled in the libr
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
constexpr struct width final : quantity_spec<length> {} width;
|
||||
constexpr auto breadth = width;
|
||||
constexpr struct height final : quantity_spec<length> {} height;
|
||||
constexpr auto depth = height;
|
||||
constexpr auto altitude = height;
|
||||
constexpr struct thickness final : quantity_spec<width> {} thickness;
|
||||
constexpr struct diameter final : quantity_spec<width> {} diameter;
|
||||
constexpr struct radius final : quantity_spec<width> {} radius;
|
||||
constexpr struct radius_of_curvature final : quantity_spec<radius> {} radius_of_curvature;
|
||||
constexpr struct path_length final : quantity_spec<length> {} path_length;
|
||||
constexpr auto arc_length = path_length;
|
||||
constexpr struct distance final : quantity_spec<path_length> {} distance;
|
||||
constexpr struct radial_distance final : quantity_spec<distance> {} radial_distance;
|
||||
constexpr struct wavelength final : quantity_spec<length> {} wavelength;
|
||||
constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
|
||||
constexpr struct displacement final : quantity_spec<length, quantity_character::vector> {} displacement;
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct width final : quantity_spec<length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
inline constexpr struct height final : quantity_spec<length> {} height;
|
||||
inline constexpr auto depth = height;
|
||||
inline constexpr auto altitude = height;
|
||||
inline constexpr struct thickness final : quantity_spec<width> {} thickness;
|
||||
inline constexpr struct diameter final : quantity_spec<width> {} diameter;
|
||||
inline constexpr struct radius final : quantity_spec<width> {} radius;
|
||||
inline constexpr struct radius_of_curvature final : quantity_spec<radius> {} radius_of_curvature;
|
||||
inline constexpr struct path_length final : quantity_spec<length> {} path_length;
|
||||
inline constexpr auto arc_length = path_length;
|
||||
inline constexpr struct distance final : quantity_spec<path_length> {} distance;
|
||||
inline constexpr struct radial_distance final : quantity_spec<distance> {} radial_distance;
|
||||
inline constexpr struct wavelength final : quantity_spec<length> {} wavelength;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
constexpr struct width final : quantity_spec<width, length> {} width;
|
||||
constexpr auto breadth = width;
|
||||
constexpr struct height final : quantity_spec<height, length> {} height;
|
||||
constexpr auto depth = height;
|
||||
constexpr auto altitude = height;
|
||||
constexpr struct thickness final : quantity_spec<thickness, width> {} thickness;
|
||||
constexpr struct diameter final : quantity_spec<diameter, width> {} diameter;
|
||||
constexpr struct radius final : quantity_spec<radius, width> {} radius;
|
||||
constexpr struct radius_of_curvature final : quantity_spec<radius_of_curvature, radius> {} radius_of_curvature;
|
||||
constexpr struct path_length final : quantity_spec<path_length, length> {} path_length;
|
||||
constexpr auto arc_length = path_length;
|
||||
constexpr struct distance final : quantity_spec<distance, path_length> {} distance;
|
||||
constexpr struct radial_distance final : quantity_spec<radial_distance, distance> {} radial_distance;
|
||||
constexpr struct wavelength final : quantity_spec<wavelength, length> {} wavelength;
|
||||
constexpr struct position_vector final : quantity_spec<position_vector, length, quantity_character::vector> {} position_vector;
|
||||
constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement;
|
||||
inline constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
inline constexpr struct width final : quantity_spec<width, length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
inline constexpr struct height final : quantity_spec<height, length> {} height;
|
||||
inline constexpr auto depth = height;
|
||||
inline constexpr auto altitude = height;
|
||||
inline constexpr struct thickness final : quantity_spec<thickness, width> {} thickness;
|
||||
inline constexpr struct diameter final : quantity_spec<diameter, width> {} diameter;
|
||||
inline 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;
|
||||
inline constexpr struct path_length final : quantity_spec<path_length, length> {} path_length;
|
||||
inline constexpr auto arc_length = path_length;
|
||||
inline constexpr struct distance final : quantity_spec<distance, path_length> {} distance;
|
||||
inline constexpr struct radial_distance final : quantity_spec<radial_distance, distance> {} radial_distance;
|
||||
inline 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;
|
||||
inline constexpr struct displacement final : quantity_spec<displacement, length, quantity_character::vector> {} displacement;
|
||||
```
|
||||
|
||||
=== "Portable"
|
||||
@ -194,16 +194,16 @@ For example, here is how the above quantity kind tree can be modeled in the libr
|
||||
```cpp
|
||||
QUANTITY_SPEC(length, dim_length);
|
||||
QUANTITY_SPEC(width, length);
|
||||
constexpr auto breadth = width;
|
||||
inline constexpr auto breadth = width;
|
||||
QUANTITY_SPEC(height, length);
|
||||
constexpr auto depth = height;
|
||||
constexpr auto altitude = height;
|
||||
inline constexpr auto depth = height;
|
||||
inline constexpr auto altitude = height;
|
||||
QUANTITY_SPEC(thickness, width);
|
||||
QUANTITY_SPEC(diameter, width);
|
||||
QUANTITY_SPEC(radius, width);
|
||||
QUANTITY_SPEC(radius_of_curvature, radius);
|
||||
QUANTITY_SPEC(path_length, length);
|
||||
constexpr auto arc_length = path_length;
|
||||
inline constexpr auto arc_length = path_length;
|
||||
QUANTITY_SPEC(distance, path_length);
|
||||
QUANTITY_SPEC(radial_distance, distance);
|
||||
QUANTITY_SPEC(wavelength, length);
|
||||
|
@ -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:
|
||||
|
||||
```cpp
|
||||
constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
|
||||
inline constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
|
||||
```
|
||||
|
||||
!!! 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:
|
||||
|
||||
```cpp
|
||||
constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```cpp
|
||||
constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
|
||||
constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
With the above, `hertz` can only be used with _frequencies_, while `becquerel` should only be used with
|
||||
@ -145,7 +145,7 @@ and then a [PrefixableUnit](concepts.md#PrefixableUnit) can be prefixed in the f
|
||||
way:
|
||||
|
||||
```cpp
|
||||
constexpr auto qm = quecto<metre>;
|
||||
inline constexpr auto qm = quecto<metre>;
|
||||
```
|
||||
|
||||
The usage of `mag_power` not only enables providing support for SI prefixes, but it can also
|
||||
@ -168,25 +168,25 @@ be explicitly expressed with predefined SI prefixes. Those include units like mi
|
||||
electronvolt:
|
||||
|
||||
```cpp
|
||||
constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
|
||||
constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt;
|
||||
inline constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```cpp
|
||||
constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
|
||||
inline 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
|
||||
is defined using a floating-point magnitude having a factor of the number π (Pi):
|
||||
|
||||
```cpp
|
||||
constexpr struct mag_pi final : magnitude<std::numbers::pi_v<long double>> {} mag_pi;
|
||||
inline constexpr struct mag_pi final : magnitude<std::numbers::pi_v<long double>> {} mag_pi;
|
||||
```
|
||||
|
||||
```cpp
|
||||
constexpr struct degree final : named_unit<{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
|
||||
inline constexpr struct degree final : named_unit<{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
|
||||
```
|
||||
|
@ -33,30 +33,30 @@ and units of derived quantities.
|
||||
=== "Dimensions"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current;
|
||||
constexpr struct dim_thermodynamic_temperature final : base_dimension<{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
|
||||
constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance;
|
||||
constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity;
|
||||
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
inline 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;
|
||||
inline 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;
|
||||
```
|
||||
|
||||
=== "Units"
|
||||
|
||||
```cpp
|
||||
constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
|
||||
constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
|
||||
constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
constexpr auto kilogram = kilo<gram>;
|
||||
inline 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;
|
||||
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
inline constexpr auto kilogram = kilo<gram>;
|
||||
|
||||
constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
|
||||
constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
|
||||
constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
|
||||
constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
|
||||
inline constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
|
||||
inline constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
|
||||
inline constexpr struct ohm final : named_unit<{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
```
|
||||
|
||||
=== "Prefixes"
|
||||
@ -75,13 +75,13 @@ and units of derived quantities.
|
||||
=== "Constants"
|
||||
|
||||
```cpp
|
||||
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 speed_of_light_in_vacuum final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
|
||||
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 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 boltzmann_constant final : named_unit<"k", mag_ratio<1'380'649, 1'000'000> * mag_power<10, -23> * joule / kelvin> {} boltzmann_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;
|
||||
constexpr struct luminous_efficacy final : named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
|
||||
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;
|
||||
inline 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
inline constexpr struct luminous_efficacy final : named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
|
||||
```
|
||||
|
||||
!!! important
|
||||
@ -105,7 +105,7 @@ and units of derived quantities.
|
||||
template name to initialize it with two symbols:
|
||||
|
||||
```cpp
|
||||
constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
```
|
||||
|
||||
|
||||
|
@ -196,7 +196,7 @@ origin.
|
||||
{style="width:80%;display: block;margin: 0 auto;"}
|
||||
|
||||
```cpp
|
||||
constexpr struct origin final : absolute_point_origin<isq::distance> {} origin;
|
||||
inline 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> qp2{delta<m>(120)}; // Compile-time error
|
||||
@ -265,8 +265,8 @@ type and unit is being used:
|
||||
{style="width:80%;display: block;margin: 0 auto;"}
|
||||
|
||||
```cpp
|
||||
constexpr struct origin1 final : absolute_point_origin<isq::distance> {} origin1;
|
||||
constexpr struct origin2 final : absolute_point_origin<isq::distance> {} origin2;
|
||||
inline constexpr struct origin1 final : absolute_point_origin<isq::distance> {} origin1;
|
||||
inline constexpr struct origin2 final : absolute_point_origin<isq::distance> {} origin2;
|
||||
|
||||
quantity_point qp1 = origin1 + 100 * m;
|
||||
quantity_point qp2 = origin2 + 120 * m;
|
||||
@ -300,10 +300,10 @@ For such cases, relative point origins should be used:
|
||||
{style="width:80%;display: block;margin: 0 auto;"}
|
||||
|
||||
```cpp
|
||||
constexpr struct A final : absolute_point_origin<isq::distance> {} A;
|
||||
constexpr struct B final : relative_point_origin<A + 10 * m> {} B;
|
||||
constexpr struct C final : relative_point_origin<B + 10 * m> {} C;
|
||||
constexpr struct D final : relative_point_origin<A + 30 * m> {} D;
|
||||
inline constexpr struct A final : absolute_point_origin<isq::distance> {} A;
|
||||
inline constexpr struct B final : relative_point_origin<A + 10 * m> {} B;
|
||||
inline constexpr struct C final : relative_point_origin<B + 10 * m> {} C;
|
||||
inline constexpr struct D final : relative_point_origin<A + 30 * m> {} D;
|
||||
|
||||
quantity_point qp1 = C + 100 * m;
|
||||
quantity_point qp2 = D + 120 * m;
|
||||
@ -408,17 +408,17 @@ point origins for this purpose:
|
||||
```cpp
|
||||
namespace si {
|
||||
|
||||
constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
constexpr auto zeroth_kelvin = absolute_zero;
|
||||
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
inline constexpr auto zeroth_kelvin = absolute_zero;
|
||||
|
||||
constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)}> {} ice_point;
|
||||
constexpr auto zeroth_degree_Celsius = ice_point;
|
||||
inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)}> {} ice_point;
|
||||
inline constexpr auto zeroth_degree_Celsius = ice_point;
|
||||
|
||||
}
|
||||
|
||||
namespace usc {
|
||||
|
||||
constexpr struct zeroth_degree_Fahrenheit final :
|
||||
inline constexpr struct zeroth_degree_Fahrenheit final :
|
||||
relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_degree_Fahrenheit;
|
||||
|
||||
}
|
||||
@ -442,16 +442,16 @@ definitions:
|
||||
```cpp
|
||||
namespace si {
|
||||
|
||||
constexpr struct kelvin final :
|
||||
inline constexpr struct kelvin final :
|
||||
named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
constexpr struct degree_Celsius final :
|
||||
inline constexpr struct degree_Celsius final :
|
||||
named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
|
||||
|
||||
}
|
||||
|
||||
namespace usc {
|
||||
|
||||
constexpr struct degree_Fahrenheit final :
|
||||
inline constexpr struct degree_Fahrenheit final :
|
||||
named_unit<{u8"℉", "`F"}, mag_ratio<5, 9> * si::degree_Celsius,
|
||||
zeroth_degree_Fahrenheit> {} degree_Fahrenheit;
|
||||
|
||||
|
@ -85,16 +85,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
constexpr struct currency final : quantity_spec<dim_currency> {} currency;
|
||||
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
inline constexpr struct currency final : quantity_spec<dim_currency> {} currency;
|
||||
|
||||
constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
|
||||
constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
|
||||
inline 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;
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto USD = us_dollar;
|
||||
constexpr auto USD_s = scaled_us_dollar;
|
||||
inline constexpr auto USD = us_dollar;
|
||||
inline constexpr auto USD_s = scaled_us_dollar;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
@ -105,16 +105,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
constexpr struct currency final : quantity_spec<currency, dim_currency> {} currency;
|
||||
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
inline constexpr struct currency final : quantity_spec<currency, dim_currency> {} currency;
|
||||
|
||||
constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
|
||||
constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
|
||||
inline 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;
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto USD = us_dollar;
|
||||
constexpr auto USD_s = scaled_us_dollar;
|
||||
inline constexpr auto USD = us_dollar;
|
||||
inline constexpr auto USD_s = scaled_us_dollar;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
@ -125,16 +125,16 @@ the `value_cast<U, Rep>(q)` which always returns the most precise result:
|
||||
=== "Portable"
|
||||
|
||||
```cpp
|
||||
constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
QUANTITY_SPEC(currency, dim_currency);
|
||||
|
||||
constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
|
||||
constexpr struct scaled_us_dollar final : named_unit<"USD_s", mag_power<10, -8> * us_dollar> {} scaled_us_dollar;
|
||||
inline 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;
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto USD = us_dollar;
|
||||
constexpr auto USD_s = scaled_us_dollar;
|
||||
inline constexpr auto USD = us_dollar;
|
||||
inline constexpr auto USD_s = scaled_us_dollar;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -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:
|
||||
|
||||
```cpp
|
||||
constexpr struct ts_origin final : relative_point_origin<chrono_point_origin<system_clock> + 1 * h> {} ts_origin;
|
||||
constexpr struct my_origin final : absolute_point_origin<isq::time> {} my_origin;
|
||||
inline 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;
|
||||
|
||||
quantity_point qp1 = sys_seconds{1s};
|
||||
auto tp1 = to_chrono_time_point(qp1); // OK
|
||||
|
@ -29,7 +29,7 @@ your code using **mp-units**:
|
||||
|
||||
// ...
|
||||
|
||||
constexpr struct horizontal_length final : quantity_spec<isq::length> {} horizontal_length;
|
||||
inline constexpr struct horizontal_length final : quantity_spec<isq::length> {} horizontal_length;
|
||||
|
||||
// ...
|
||||
|
||||
@ -45,7 +45,7 @@ your code using **mp-units**:
|
||||
|
||||
// ...
|
||||
|
||||
constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
|
||||
// ...
|
||||
|
||||
@ -65,7 +65,7 @@ your code using **mp-units**:
|
||||
|
||||
// ...
|
||||
|
||||
constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
|
||||
// ...
|
||||
|
||||
@ -85,7 +85,7 @@ your code using **mp-units**:
|
||||
|
||||
// ...
|
||||
|
||||
constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
inline constexpr struct horizontal_length final : quantity_spec<horizontal_length, isq::length> {} horizontal_length;
|
||||
|
||||
// ...
|
||||
|
||||
|
@ -40,22 +40,22 @@ import mp_units.core;
|
||||
using namespace mp_units;
|
||||
|
||||
// clang-format off
|
||||
constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
inline constexpr struct dim_currency final : base_dimension<"$"> {} dim_currency;
|
||||
|
||||
QUANTITY_SPEC(currency, dim_currency);
|
||||
|
||||
constexpr struct euro final : named_unit<"EUR", kind_of<currency>> {} euro;
|
||||
constexpr struct us_dollar final : named_unit<"USD", kind_of<currency>> {} us_dollar;
|
||||
constexpr struct great_british_pound final : named_unit<"GBP", kind_of<currency>> {} great_british_pound;
|
||||
constexpr struct japanese_jen final : named_unit<"JPY", kind_of<currency>> {} japanese_jen;
|
||||
inline 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;
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto EUR = euro;
|
||||
constexpr auto USD = us_dollar;
|
||||
constexpr auto GBP = great_british_pound;
|
||||
constexpr auto JPY = japanese_jen;
|
||||
inline constexpr auto EUR = euro;
|
||||
inline constexpr auto USD = us_dollar;
|
||||
inline constexpr auto GBP = great_british_pound;
|
||||
inline constexpr auto JPY = japanese_jen;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -44,7 +44,7 @@ import mp_units;
|
||||
|
||||
namespace geographic {
|
||||
|
||||
constexpr struct mean_sea_level final : mp_units::absolute_point_origin<mp_units::isq::altitude> {
|
||||
inline constexpr struct mean_sea_level final : mp_units::absolute_point_origin<mp_units::isq::altitude> {
|
||||
} 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 {
|
||||
|
||||
constexpr struct equator final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
|
||||
inline constexpr struct equator final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
|
||||
} equator;
|
||||
constexpr struct prime_meridian final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
|
||||
inline constexpr struct prime_meridian final : mp_units::absolute_point_origin<mp_units::isq::angular_measure> {
|
||||
} prime_meridian;
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ import mp_units.core;
|
||||
#include <mp-units/framework/customization_points.h>
|
||||
#endif
|
||||
|
||||
constexpr struct validated_tag {
|
||||
inline constexpr struct validated_tag {
|
||||
} validated;
|
||||
|
||||
template<std::movable T, std::predicate<T> Validator>
|
||||
|
@ -58,8 +58,8 @@ QUANTITY_SPEC(horizontal_length, isq::length);
|
||||
// with a constrained quantity equation
|
||||
QUANTITY_SPEC(horizontal_area, isq::area, horizontal_length* isq::width);
|
||||
|
||||
constexpr auto g = 1 * si::standard_gravity;
|
||||
constexpr auto air_density = isq::mass_density(1.225 * kg / m3);
|
||||
inline constexpr auto g = 1 * si::standard_gravity;
|
||||
inline constexpr auto air_density = isq::mass_density(1.225 * kg / m3);
|
||||
|
||||
class StorageTank {
|
||||
quantity<horizontal_area[m2]> base_;
|
||||
|
@ -119,7 +119,7 @@ hae_altitude<M> to_hae(msl_altitude msl, position<long double> pos)
|
||||
// **** HAL ****
|
||||
|
||||
// clang-format off
|
||||
constexpr struct height_above_launch final : absolute_point_origin<isq::altitude> {} height_above_launch;
|
||||
inline constexpr struct height_above_launch final : absolute_point_origin<isq::altitude> {} height_above_launch;
|
||||
// clang-format on
|
||||
|
||||
using hal_altitude = quantity_point<isq::altitude[si::metre], height_above_launch>;
|
||||
|
@ -104,7 +104,7 @@ namespace std {
|
||||
struct from_range_t {
|
||||
explicit from_range_t() = default;
|
||||
};
|
||||
constexpr from_range_t from_range{};
|
||||
inline constexpr from_range_t from_range{};
|
||||
|
||||
} // namespace std
|
||||
|
||||
|
@ -63,9 +63,9 @@ constexpr basic_fixed_string superscript_number<8> = u8"\u2078";
|
||||
template<>
|
||||
constexpr basic_fixed_string superscript_number<9> = u8"\u2079";
|
||||
|
||||
constexpr symbol_text superscript_minus(u8"\u207b", "-");
|
||||
inline constexpr symbol_text superscript_minus(u8"\u207b", "-");
|
||||
|
||||
constexpr symbol_text superscript_prefix(u8"", "^");
|
||||
inline constexpr symbol_text superscript_prefix(u8"", "^");
|
||||
|
||||
template<std::intmax_t Value>
|
||||
[[nodiscard]] consteval auto superscript_helper()
|
||||
|
@ -28,14 +28,14 @@
|
||||
|
||||
#if MP_UNITS_API_NO_CRTP
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name final : ::mp_units::quantity_spec<__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#else
|
||||
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
constexpr struct name final : ::mp_units::quantity_spec<name, __VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC(name, ...) \
|
||||
inline constexpr struct name final : ::mp_units::quantity_spec<name, __VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#endif
|
||||
|
@ -115,9 +115,9 @@ struct dimension_interface {
|
||||
* For example:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
* constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
* constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
* inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
* inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
* inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
* @endcode
|
||||
*
|
||||
* @note A common convention in this library is to assign the same name for a type and an object of this type.
|
||||
@ -184,7 +184,9 @@ 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
|
||||
* "dimensionless".
|
||||
*/
|
||||
MP_UNITS_EXPORT constexpr struct dimension_one final : detail::dimension_interface, detail::derived_dimension_impl<> {
|
||||
MP_UNITS_EXPORT inline constexpr struct dimension_one final :
|
||||
detail::dimension_interface,
|
||||
detail::derived_dimension_impl<> {
|
||||
} dimension_one;
|
||||
|
||||
namespace detail {
|
||||
|
@ -725,12 +725,12 @@ MP_UNITS_EXPORT_BEGIN
|
||||
*/
|
||||
#if MP_UNITS_COMP_CLANG
|
||||
|
||||
constexpr struct mag_pi : magnitude<mag_value{std::numbers::pi_v<long double>}> {
|
||||
inline constexpr struct mag_pi : magnitude<mag_value{std::numbers::pi_v<long double>}> {
|
||||
} mag_pi;
|
||||
|
||||
#else
|
||||
|
||||
constexpr struct mag_pi : magnitude<std::numbers::pi_v<long double>> {
|
||||
inline constexpr struct mag_pi : magnitude<std::numbers::pi_v<long double>> {
|
||||
} mag_pi;
|
||||
|
||||
#endif
|
||||
@ -959,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);
|
||||
}
|
||||
|
||||
constexpr symbol_text base_multiplier(u8"× 10", "x 10");
|
||||
inline constexpr symbol_text base_multiplier(u8"× 10", "x 10");
|
||||
|
||||
template<Magnitude auto M>
|
||||
[[nodiscard]] consteval auto magnitude_text()
|
||||
|
@ -189,7 +189,7 @@ struct quantity_spec_interface : quantity_spec_interface_base {
|
||||
|
||||
MP_UNITS_EXPORT_BEGIN
|
||||
|
||||
constexpr struct is_kind {
|
||||
inline constexpr struct is_kind {
|
||||
} is_kind;
|
||||
|
||||
/**
|
||||
@ -235,13 +235,13 @@ MP_UNITS_EXPORT_END
|
||||
* For example:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
* constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
* constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
* inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
* inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
* inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
*
|
||||
* constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
* constexpr struct mass final : quantity_spec<dim_mass> {} mass;
|
||||
* constexpr struct time final : quantity_spec<dim_time> {} time;
|
||||
* inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
* inline constexpr struct mass final : quantity_spec<dim_mass> {} mass;
|
||||
* inline constexpr struct time final : quantity_spec<dim_time> {} time;
|
||||
* @endcode
|
||||
*
|
||||
* @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:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct area final : quantity_spec<pow<2>(length)> {} area;
|
||||
* constexpr struct volume final : quantity_spec<pow<3>(length)> {} volume;
|
||||
* constexpr struct velocity final : quantity_spec<position_vector / duration> {} velocity;
|
||||
* constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
* constexpr struct force final : quantity_spec<mass * acceleration, quantity_character::vector> {} force;
|
||||
* constexpr struct power final : quantity_spec<force * velocity, quantity_character::scalar> {} power;
|
||||
* inline constexpr struct area final : quantity_spec<pow<2>(length)> {} area;
|
||||
* inline constexpr struct volume final : quantity_spec<pow<3>(length)> {} volume;
|
||||
* inline constexpr struct velocity final : quantity_spec<position_vector / duration> {} velocity;
|
||||
* inline constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
* inline 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;
|
||||
* @endcode
|
||||
*
|
||||
* @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:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct width final : quantity_spec<length> {} width;
|
||||
* constexpr struct height final : quantity_spec<length> {} height;
|
||||
* constexpr struct diameter final : quantity_spec<width> {} diameter;
|
||||
* constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
|
||||
* inline constexpr struct width final : quantity_spec<length> {} width;
|
||||
* inline constexpr struct height final : quantity_spec<length> {} height;
|
||||
* inline constexpr struct diameter final : quantity_spec<width> {} diameter;
|
||||
* inline constexpr struct position_vector final : quantity_spec<length, quantity_character::vector> {} position_vector;
|
||||
* @endcode
|
||||
*
|
||||
* @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:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct angular_measure final : quantity_spec<dimensionless, arc_length / radius, is_kind> {} angular_measure;
|
||||
* constexpr struct velocity final : quantity_spec<speed, position_vector / duration> {} velocity;
|
||||
* constexpr struct weight final : quantity_spec<force, mass * acceleration_of_free_fall> {} weight;
|
||||
* constexpr struct kinetic_energy final : quantity_spec<mechanical_energy, mass * pow<2>(speed)> {} kinetic_energy;
|
||||
* inline 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;
|
||||
* inline 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;
|
||||
* @endcode
|
||||
*
|
||||
* @note A common convention in this library is to assign the same name for a type and an object of this type.
|
||||
|
@ -45,15 +45,15 @@ namespace mp_units {
|
||||
* @code{.cpp}
|
||||
* // hypothetical natural system of units for c=1
|
||||
*
|
||||
* constexpr struct second final : named_unit<"s"> {} second;
|
||||
* constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
* constexpr struct gram final : named_unit<"g"> {} gram;
|
||||
* constexpr auto kilogram = si::kilo<gram>;
|
||||
* inline constexpr struct second final : named_unit<"s"> {} second;
|
||||
* inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
* inline constexpr struct gram final : named_unit<"g"> {} gram;
|
||||
* inline constexpr auto kilogram = si::kilo<gram>;
|
||||
*
|
||||
* constexpr struct time : system_reference<isq::time, second> {} time;
|
||||
* constexpr struct length : system_reference<isq::length, second> {} length;
|
||||
* constexpr struct speed : system_reference<isq::speed, second / second> {} speed;
|
||||
* constexpr struct force : system_reference<isq::force, kilogram / second> {} force;
|
||||
* inline constexpr struct time : system_reference<isq::time, second> {} time;
|
||||
* inline constexpr struct length : system_reference<isq::length, second> {} length;
|
||||
* inline constexpr struct speed : system_reference<isq::speed, second / second> {} speed;
|
||||
* inline constexpr struct force : system_reference<isq::force, kilogram / second> {} force;
|
||||
* @endcode
|
||||
*
|
||||
* @tparam Q quantity for which a unit is being assigned
|
||||
|
@ -256,12 +256,12 @@ constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true;
|
||||
* For example:
|
||||
*
|
||||
* @code{.cpp}
|
||||
* constexpr struct second final : named_unit<"s", kind_of<time>> {} second;
|
||||
* constexpr struct metre final : named_unit<"m", kind_of<length> {} metre;
|
||||
* constexpr struct hertz final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
|
||||
* constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
* constexpr struct degree_Celsius final : named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {}
|
||||
* degree_Celsius; constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
* inline constexpr struct second final : named_unit<"s", kind_of<time>> {} second;
|
||||
* inline 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;
|
||||
* inline 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> {}
|
||||
* degree_Celsius; inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
|
||||
* @endcode
|
||||
*
|
||||
* @note A common convention in this library is to assign the same name for a type and an object of this type.
|
||||
@ -388,7 +388,7 @@ struct named_unit<Symbol, U, QS, PO> : decltype(U)::_base_type_ {
|
||||
* template<PrefixableUnit auto U>
|
||||
* constexpr kilo_<U> kilo;
|
||||
*
|
||||
* constexpr auto kilogram = si::kilo<gram>;
|
||||
* inline constexpr auto kilogram = si::kilo<gram>;
|
||||
* @endcode
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
// clang-format off
|
||||
MP_UNITS_EXPORT constexpr struct one final : detail::derived_unit_impl<> {} one;
|
||||
MP_UNITS_EXPORT inline constexpr struct one final : detail::derived_unit_impl<> {} one;
|
||||
// clang-format on
|
||||
|
||||
namespace detail {
|
||||
@ -611,10 +611,10 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Unit U>
|
||||
|
||||
// common dimensionless units
|
||||
// clang-format off
|
||||
constexpr struct percent final : named_unit<"%", mag_ratio<1, 100> * one> {} percent;
|
||||
constexpr struct per_mille final : named_unit<symbol_text{u8"‰", "%o"}, mag_ratio<1, 1000> * one> {} per_mille;
|
||||
constexpr struct parts_per_million final : named_unit<"ppm", mag_ratio<1, 1'000'000> * one> {} parts_per_million;
|
||||
constexpr auto ppm = parts_per_million;
|
||||
inline 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;
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
|
||||
|
@ -184,7 +184,7 @@ template<Unit auto ToU, Representation ToRep, typename QP>
|
||||
* 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.
|
||||
*
|
||||
* constexpr struct A : absolute_point_origin<A, isq::distance> A;
|
||||
* inline constexpr struct A : absolute_point_origin<A, isq::distance> A;
|
||||
*
|
||||
* using ToQ = quantity<mm, int>;
|
||||
* 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"
|
||||
* (e.g. non-truncating) conversion. In truncating cases an explicit cast have to be used.
|
||||
*
|
||||
* constexpr struct A : absolute_point_origin<A, isq::distance> A;
|
||||
* constexpr struct B : relative_point_origin<A + 1*m> B;
|
||||
* inline constexpr struct A : absolute_point_origin<A, isq::distance> A;
|
||||
* inline constexpr struct B : relative_point_origin<A + 1*m> B;
|
||||
*
|
||||
* using ToQP = quantity_point<mm, B, int>;
|
||||
* auto qp = value_cast<ToQP>(quantity_point{1.23 * m});
|
||||
|
@ -36,26 +36,26 @@ namespace mp_units {
|
||||
namespace angular {
|
||||
|
||||
// clang-format off
|
||||
constexpr struct dim_angle final : base_dimension<"A"> {} dim_angle;
|
||||
inline constexpr struct dim_angle final : base_dimension<"A"> {} dim_angle;
|
||||
QUANTITY_SPEC(angle, dim_angle);
|
||||
QUANTITY_SPEC(solid_angle, pow<2>(angle));
|
||||
|
||||
constexpr struct radian final : named_unit<"rad", kind_of<angle>> {} radian;
|
||||
constexpr struct revolution final : named_unit<"rev", mag<2> * mag_pi * radian> {} revolution;
|
||||
constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_ratio<1, 360> * revolution> {} degree;
|
||||
constexpr struct gradian final : named_unit<symbol_text{u8"ᵍ", "grad"}, mag_ratio<1, 400> * revolution> {} gradian;
|
||||
constexpr struct steradian final : named_unit<"sr", square(radian)> {} steradian;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct steradian final : named_unit<"sr", square(radian)> {} steradian;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto rad = radian;
|
||||
constexpr auto rev = revolution;
|
||||
constexpr auto deg = degree;
|
||||
constexpr auto grad = gradian;
|
||||
constexpr auto sr = steradian;
|
||||
constexpr auto rad2 = square(radian);
|
||||
constexpr auto deg2 = square(degree);
|
||||
inline constexpr auto rad = radian;
|
||||
inline constexpr auto rev = revolution;
|
||||
inline constexpr auto deg = degree;
|
||||
inline constexpr auto grad = gradian;
|
||||
inline constexpr auto sr = steradian;
|
||||
inline constexpr auto rad2 = square(radian);
|
||||
inline constexpr auto deg2 = square(degree);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -35,35 +35,35 @@ MP_UNITS_EXPORT
|
||||
namespace mp_units::cgs {
|
||||
|
||||
// clang-format off
|
||||
constexpr auto centimetre = si::centi<si::metre>;
|
||||
constexpr auto gram = si::gram;
|
||||
constexpr auto second = si::second;
|
||||
constexpr struct gal final : named_unit<"Gal", centimetre / square(second)> {} gal;
|
||||
constexpr struct dyne final : named_unit<"dyn", gram * centimetre / square(second)> {} dyne;
|
||||
constexpr struct erg final : named_unit<"erg", dyne * centimetre> {} erg;
|
||||
constexpr struct barye final : named_unit<"Ba", gram / (centimetre * square(second))> {} barye;
|
||||
constexpr struct poise final : named_unit<"P", gram / (centimetre * second)> {} poise;
|
||||
constexpr struct stokes final : named_unit<"St", square(centimetre) / second> {} stokes;
|
||||
constexpr struct kayser final : named_unit<"K", one / centimetre> {} kayser;
|
||||
inline constexpr auto centimetre = si::centi<si::metre>;
|
||||
inline constexpr auto gram = si::gram;
|
||||
inline constexpr auto second = si::second;
|
||||
inline constexpr struct gal final : named_unit<"Gal", centimetre / square(second)> {} gal;
|
||||
inline constexpr struct dyne final : named_unit<"dyn", gram * centimetre / square(second)> {} dyne;
|
||||
inline constexpr struct erg final : named_unit<"erg", dyne * centimetre> {} erg;
|
||||
inline constexpr struct barye final : named_unit<"Ba", gram / (centimetre * square(second))> {} barye;
|
||||
inline constexpr struct poise final : named_unit<"P", gram / (centimetre * second)> {} poise;
|
||||
inline constexpr struct stokes final : named_unit<"St", square(centimetre) / second> {} stokes;
|
||||
inline constexpr struct kayser final : named_unit<"K", one / centimetre> {} kayser;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto cm = centimetre;
|
||||
constexpr auto g = gram;
|
||||
constexpr auto s = second;
|
||||
constexpr auto Gal = gal;
|
||||
constexpr auto dyn = dyne;
|
||||
constexpr auto Ba = barye;
|
||||
constexpr auto P = poise;
|
||||
constexpr auto St = stokes;
|
||||
constexpr auto K = kayser;
|
||||
inline constexpr auto cm = centimetre;
|
||||
inline constexpr auto g = gram;
|
||||
inline constexpr auto s = second;
|
||||
inline constexpr auto Gal = gal;
|
||||
inline constexpr auto dyn = dyne;
|
||||
inline constexpr auto Ba = barye;
|
||||
inline constexpr auto P = poise;
|
||||
inline constexpr auto St = stokes;
|
||||
inline constexpr auto K = kayser;
|
||||
|
||||
// commonly used squared and cubic units
|
||||
constexpr auto cm2 = square(centimetre);
|
||||
constexpr auto cm3 = cubic(centimetre);
|
||||
constexpr auto s2 = square(second);
|
||||
constexpr auto s3 = cubic(second);
|
||||
inline constexpr auto cm2 = square(centimetre);
|
||||
inline constexpr auto cm3 = cubic(centimetre);
|
||||
inline constexpr auto s2 = square(second);
|
||||
inline constexpr auto s3 = cubic(second);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -49,64 +49,64 @@ using si::electronvolt;
|
||||
// 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://www.fedlex.admin.ch/eli/cc/1994/3109_3109_3109/de
|
||||
constexpr struct barn final : named_unit<"b", mag_power<10, -28> * square(si::metre)> {} barn;
|
||||
inline constexpr struct barn final : named_unit<"b", mag_power<10, -28> * square(si::metre)> {} barn;
|
||||
|
||||
// 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;
|
||||
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 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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
|
||||
// speed
|
||||
constexpr auto speed_of_light = si::si2019::speed_of_light_in_vacuum;
|
||||
inline constexpr auto speed_of_light = si::si2019::speed_of_light_in_vacuum;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
using si::unit_symbols::eV;
|
||||
|
||||
constexpr auto qeV = si::quecto<electronvolt>;
|
||||
constexpr auto reV = si::ronto<electronvolt>;
|
||||
constexpr auto yeV = si::yocto<electronvolt>;
|
||||
constexpr auto zeV = si::zepto<electronvolt>;
|
||||
constexpr auto aeV = si::atto<electronvolt>;
|
||||
constexpr auto feV = si::femto<electronvolt>;
|
||||
constexpr auto peV = si::pico<electronvolt>;
|
||||
constexpr auto neV = si::nano<electronvolt>;
|
||||
constexpr auto ueV = si::micro<electronvolt>;
|
||||
constexpr auto meV = si::milli<electronvolt>;
|
||||
constexpr auto ceV = si::centi<electronvolt>;
|
||||
constexpr auto deV = si::deci<electronvolt>;
|
||||
constexpr auto daeV = si::deca<electronvolt>;
|
||||
constexpr auto heV = si::hecto<electronvolt>;
|
||||
constexpr auto keV = si::kilo<electronvolt>;
|
||||
constexpr auto MeV = si::mega<electronvolt>;
|
||||
constexpr auto GeV = si::giga<electronvolt>;
|
||||
constexpr auto TeV = si::tera<electronvolt>;
|
||||
constexpr auto PeV = si::peta<electronvolt>;
|
||||
constexpr auto EeV = si::exa<electronvolt>;
|
||||
constexpr auto ZeV = si::zetta<electronvolt>;
|
||||
constexpr auto YeV = si::yotta<electronvolt>;
|
||||
constexpr auto ReV = si::ronna<electronvolt>;
|
||||
constexpr auto QeV = si::quetta<electronvolt>;
|
||||
inline constexpr auto qeV = si::quecto<electronvolt>;
|
||||
inline constexpr auto reV = si::ronto<electronvolt>;
|
||||
inline constexpr auto yeV = si::yocto<electronvolt>;
|
||||
inline constexpr auto zeV = si::zepto<electronvolt>;
|
||||
inline constexpr auto aeV = si::atto<electronvolt>;
|
||||
inline constexpr auto feV = si::femto<electronvolt>;
|
||||
inline constexpr auto peV = si::pico<electronvolt>;
|
||||
inline constexpr auto neV = si::nano<electronvolt>;
|
||||
inline constexpr auto ueV = si::micro<electronvolt>;
|
||||
inline constexpr auto meV = si::milli<electronvolt>;
|
||||
inline constexpr auto ceV = si::centi<electronvolt>;
|
||||
inline constexpr auto deV = si::deci<electronvolt>;
|
||||
inline constexpr auto daeV = si::deca<electronvolt>;
|
||||
inline constexpr auto heV = si::hecto<electronvolt>;
|
||||
inline constexpr auto keV = si::kilo<electronvolt>;
|
||||
inline constexpr auto MeV = si::mega<electronvolt>;
|
||||
inline constexpr auto GeV = si::giga<electronvolt>;
|
||||
inline constexpr auto TeV = si::tera<electronvolt>;
|
||||
inline constexpr auto PeV = si::peta<electronvolt>;
|
||||
inline constexpr auto EeV = si::exa<electronvolt>;
|
||||
inline constexpr auto ZeV = si::zetta<electronvolt>;
|
||||
inline constexpr auto YeV = si::yotta<electronvolt>;
|
||||
inline constexpr auto ReV = si::ronna<electronvolt>;
|
||||
inline constexpr auto QeV = si::quetta<electronvolt>;
|
||||
|
||||
constexpr auto qb = si::quecto<barn>;
|
||||
constexpr auto rb = si::ronto<barn>;
|
||||
constexpr auto yb = si::yocto<barn>;
|
||||
constexpr auto zb = si::zepto<barn>;
|
||||
constexpr auto ab = si::atto<barn>;
|
||||
constexpr auto fb = si::femto<barn>;
|
||||
constexpr auto pb = si::pico<barn>;
|
||||
constexpr auto nb = si::nano<barn>;
|
||||
constexpr auto ub = si::micro<barn>;
|
||||
constexpr auto mb = si::milli<barn>;
|
||||
constexpr auto b = barn;
|
||||
inline constexpr auto qb = si::quecto<barn>;
|
||||
inline constexpr auto rb = si::ronto<barn>;
|
||||
inline constexpr auto yb = si::yocto<barn>;
|
||||
inline constexpr auto zb = si::zepto<barn>;
|
||||
inline constexpr auto ab = si::atto<barn>;
|
||||
inline constexpr auto fb = si::femto<barn>;
|
||||
inline constexpr auto pb = si::pico<barn>;
|
||||
inline constexpr auto nb = si::nano<barn>;
|
||||
inline constexpr auto ub = si::micro<barn>;
|
||||
inline constexpr auto mb = si::milli<barn>;
|
||||
inline constexpr auto b = barn;
|
||||
|
||||
constexpr auto m_e = electron_mass;
|
||||
constexpr auto m_p = proton_mass;
|
||||
constexpr auto m_n = neutron_mass;
|
||||
inline constexpr auto m_e = electron_mass;
|
||||
inline constexpr auto m_p = proton_mass;
|
||||
inline constexpr auto m_n = neutron_mass;
|
||||
|
||||
constexpr auto c = speed_of_light;
|
||||
constexpr auto c2 = square(speed_of_light);
|
||||
inline constexpr auto c = speed_of_light;
|
||||
inline constexpr auto c2 = square(speed_of_light);
|
||||
|
||||
} // namespace unit_symbols
|
||||
} // namespace hep
|
||||
|
@ -39,65 +39,65 @@ namespace mp_units::iau {
|
||||
|
||||
// clang-format off
|
||||
// time
|
||||
constexpr struct day final : named_unit<"D", si::day> {} day;
|
||||
constexpr struct Julian_year final : named_unit<"a", mag_ratio<365'25, 100> * day> {} Julian_year;
|
||||
inline 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;
|
||||
|
||||
// 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)
|
||||
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 Jupiter_mass final : named_unit<"M_JUP", mag_ratio<1'898, 1'000> * mag_power<10, 27> * si::kilogram> {} Jupiter_mass;
|
||||
constexpr struct Earth_mass final : named_unit<"M_EARTH", mag_ratio<59'742, 10'000> * mag_power<10, 24> * si::kilogram> {} Earth_mass;
|
||||
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;
|
||||
inline 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;
|
||||
|
||||
// length
|
||||
constexpr auto astronomical_unit = si::astronomical_unit;
|
||||
inline constexpr auto astronomical_unit = si::astronomical_unit;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Lunar_distance_(astronomy)
|
||||
constexpr struct lunar_distance final : named_unit<"LD", mag<384'399> * si::kilo<si::metre>> {} lunar_distance;
|
||||
inline constexpr struct lunar_distance final : named_unit<"LD", mag<384'399> * si::kilo<si::metre>> {} lunar_distance;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Light-year
|
||||
constexpr struct light_year final : named_unit<"ly", mag<9'460'730'472'580'800> * si::metre> {} light_year;
|
||||
inline 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
|
||||
constexpr struct parsec final : named_unit<"pc", astronomical_unit / (mag_ratio<1, 3600> * si::degree)> {} parsec;
|
||||
inline constexpr struct parsec final : named_unit<"pc", astronomical_unit / (mag_ratio<1, 3600> * si::degree)> {} parsec;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Angstrom
|
||||
constexpr struct angstrom final : named_unit<symbol_text{u8"Å", "A"}, mag_power<10, -10> * si::metre> {} angstrom;
|
||||
inline constexpr struct angstrom final : named_unit<symbol_text{u8"Å", "A"}, mag_power<10, -10> * si::metre> {} angstrom;
|
||||
|
||||
// selected constants
|
||||
// https://en.wikipedia.org/wiki/Astronomical_constant
|
||||
constexpr struct gaussian_gravitational_constant final :
|
||||
inline 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;
|
||||
|
||||
constexpr struct speed_of_light final :
|
||||
inline constexpr struct speed_of_light final :
|
||||
named_unit<symbol_text{u8"c₀", "c_0"}, si::si2019::speed_of_light_in_vacuum> {} speed_of_light;
|
||||
|
||||
constexpr struct constant_of_gravitation final :
|
||||
inline 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;
|
||||
|
||||
constexpr struct hubble_constant final :
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto D = day;
|
||||
constexpr auto a = Julian_year;
|
||||
inline constexpr auto D = day;
|
||||
inline constexpr auto a = Julian_year;
|
||||
|
||||
constexpr auto M_SUN = solar_mass;
|
||||
constexpr auto M_JUP = Jupiter_mass;
|
||||
constexpr auto M_EARTH = Earth_mass;
|
||||
inline constexpr auto M_SUN = solar_mass;
|
||||
inline constexpr auto M_JUP = Jupiter_mass;
|
||||
inline constexpr auto M_EARTH = Earth_mass;
|
||||
|
||||
constexpr auto au = astronomical_unit;
|
||||
constexpr auto LD = lunar_distance;
|
||||
constexpr auto ly = light_year;
|
||||
constexpr auto pc = parsec;
|
||||
constexpr auto A = angstrom;
|
||||
inline constexpr auto au = astronomical_unit;
|
||||
inline constexpr auto LD = lunar_distance;
|
||||
inline constexpr auto ly = light_year;
|
||||
inline constexpr auto pc = parsec;
|
||||
inline constexpr auto A = angstrom;
|
||||
|
||||
constexpr auto k = gaussian_gravitational_constant;
|
||||
constexpr auto c_0 = speed_of_light;
|
||||
constexpr auto G = constant_of_gravitation;
|
||||
constexpr auto H_0 = hubble_constant;
|
||||
inline constexpr auto k = gaussian_gravitational_constant;
|
||||
inline constexpr auto c_0 = speed_of_light;
|
||||
inline constexpr auto G = constant_of_gravitation;
|
||||
inline constexpr auto H_0 = hubble_constant;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -36,40 +36,40 @@ namespace mp_units::iec80000 {
|
||||
|
||||
// dimensions of base quantities
|
||||
// clang-format off
|
||||
constexpr struct dim_traffic_intensity final : base_dimension<"A"> {} dim_traffic_intensity;
|
||||
inline constexpr struct dim_traffic_intensity final : base_dimension<"A"> {} dim_traffic_intensity;
|
||||
// clang-format on
|
||||
|
||||
// quantities
|
||||
QUANTITY_SPEC(traffic_intensity, dim_traffic_intensity);
|
||||
QUANTITY_SPEC(traffic_offered_intensity, traffic_intensity);
|
||||
QUANTITY_SPEC(traffic_carried_intensity, traffic_intensity);
|
||||
constexpr auto traffic_load = traffic_carried_intensity;
|
||||
inline constexpr auto traffic_load = traffic_carried_intensity;
|
||||
QUANTITY_SPEC(mean_queue_length, dimensionless);
|
||||
QUANTITY_SPEC(loss_probability, dimensionless);
|
||||
QUANTITY_SPEC(waiting_probability, dimensionless);
|
||||
QUANTITY_SPEC(call_intensity, inverse(isq::duration));
|
||||
constexpr auto calling_rate = call_intensity;
|
||||
inline constexpr auto calling_rate = call_intensity;
|
||||
QUANTITY_SPEC(completed_call_intensity, call_intensity);
|
||||
QUANTITY_SPEC(storage_capacity, dimensionless, is_kind);
|
||||
constexpr auto storage_size = storage_capacity;
|
||||
inline constexpr auto storage_size = storage_capacity;
|
||||
QUANTITY_SPEC(equivalent_binary_storage_capacity, storage_capacity);
|
||||
QUANTITY_SPEC(transfer_rate, storage_capacity / isq::duration);
|
||||
QUANTITY_SPEC(period_of_data_elements, isq::period, inverse(transfer_rate));
|
||||
QUANTITY_SPEC(binary_digit_rate, transfer_rate);
|
||||
constexpr auto bit_rate = binary_digit_rate;
|
||||
inline constexpr auto bit_rate = binary_digit_rate;
|
||||
QUANTITY_SPEC(period_of_binary_digits, isq::period, inverse(binary_digit_rate));
|
||||
constexpr auto bit_period = period_of_binary_digits;
|
||||
inline constexpr auto bit_period = period_of_binary_digits;
|
||||
QUANTITY_SPEC(equivalent_binary_digit_rate, binary_digit_rate);
|
||||
constexpr auto equivalent_bit_rate = bit_rate;
|
||||
inline constexpr auto equivalent_bit_rate = bit_rate;
|
||||
QUANTITY_SPEC(modulation_rate, inverse(isq::duration));
|
||||
constexpr auto line_digit_rate = modulation_rate;
|
||||
inline constexpr auto line_digit_rate = modulation_rate;
|
||||
QUANTITY_SPEC(quantizing_distortion_power, isq::power);
|
||||
QUANTITY_SPEC(carrier_power, isq::power);
|
||||
QUANTITY_SPEC(signal_energy_per_binary_digit, carrier_power* period_of_binary_digits);
|
||||
QUANTITY_SPEC(error_probability, dimensionless);
|
||||
QUANTITY_SPEC(Hamming_distance, dimensionless);
|
||||
QUANTITY_SPEC(clock_frequency, isq::frequency);
|
||||
constexpr auto clock_rate = clock_frequency;
|
||||
inline constexpr auto clock_rate = clock_frequency;
|
||||
QUANTITY_SPEC(decision_content, dimensionless);
|
||||
|
||||
// TODO how to model information_content and the following quantities???
|
||||
|
@ -31,81 +31,81 @@ MP_UNITS_EXPORT
|
||||
namespace mp_units::iec80000::unit_symbols {
|
||||
|
||||
// bit
|
||||
constexpr auto kbit = si::kilo<bit>;
|
||||
constexpr auto Mbit = si::mega<bit>;
|
||||
constexpr auto Gbit = si::giga<bit>;
|
||||
constexpr auto Tbit = si::tera<bit>;
|
||||
constexpr auto Pbit = si::peta<bit>;
|
||||
constexpr auto Ebit = si::exa<bit>;
|
||||
constexpr auto Zbit = si::zetta<bit>;
|
||||
constexpr auto Ybit = si::yotta<bit>;
|
||||
constexpr auto Rbit = si::ronna<bit>;
|
||||
constexpr auto Qbit = si::quetta<bit>;
|
||||
inline constexpr auto kbit = si::kilo<bit>;
|
||||
inline constexpr auto Mbit = si::mega<bit>;
|
||||
inline constexpr auto Gbit = si::giga<bit>;
|
||||
inline constexpr auto Tbit = si::tera<bit>;
|
||||
inline constexpr auto Pbit = si::peta<bit>;
|
||||
inline constexpr auto Ebit = si::exa<bit>;
|
||||
inline constexpr auto Zbit = si::zetta<bit>;
|
||||
inline constexpr auto Ybit = si::yotta<bit>;
|
||||
inline constexpr auto Rbit = si::ronna<bit>;
|
||||
inline constexpr auto Qbit = si::quetta<bit>;
|
||||
|
||||
constexpr auto Kibit = kibi<bit>;
|
||||
constexpr auto Mibit = mebi<bit>;
|
||||
constexpr auto Gibit = gibi<bit>;
|
||||
constexpr auto Tibit = tebi<bit>;
|
||||
constexpr auto Pibit = pebi<bit>;
|
||||
constexpr auto Eibit = exbi<bit>;
|
||||
inline constexpr auto Kibit = kibi<bit>;
|
||||
inline constexpr auto Mibit = mebi<bit>;
|
||||
inline constexpr auto Gibit = gibi<bit>;
|
||||
inline constexpr auto Tibit = tebi<bit>;
|
||||
inline constexpr auto Pibit = pebi<bit>;
|
||||
inline constexpr auto Eibit = exbi<bit>;
|
||||
|
||||
// octet
|
||||
constexpr auto o = octet;
|
||||
inline constexpr auto o = octet;
|
||||
|
||||
constexpr auto ko = si::kilo<octet>;
|
||||
constexpr auto Mo = si::mega<octet>;
|
||||
constexpr auto Go = si::giga<octet>;
|
||||
constexpr auto To = si::tera<octet>;
|
||||
constexpr auto Po = si::peta<octet>;
|
||||
constexpr auto Eo = si::exa<octet>;
|
||||
constexpr auto Zo = si::zetta<octet>;
|
||||
constexpr auto Yo = si::yotta<octet>;
|
||||
constexpr auto Ro = si::ronna<octet>;
|
||||
constexpr auto Qo = si::quetta<octet>;
|
||||
inline constexpr auto ko = si::kilo<octet>;
|
||||
inline constexpr auto Mo = si::mega<octet>;
|
||||
inline constexpr auto Go = si::giga<octet>;
|
||||
inline constexpr auto To = si::tera<octet>;
|
||||
inline constexpr auto Po = si::peta<octet>;
|
||||
inline constexpr auto Eo = si::exa<octet>;
|
||||
inline constexpr auto Zo = si::zetta<octet>;
|
||||
inline constexpr auto Yo = si::yotta<octet>;
|
||||
inline constexpr auto Ro = si::ronna<octet>;
|
||||
inline constexpr auto Qo = si::quetta<octet>;
|
||||
|
||||
constexpr auto Kio = kibi<octet>;
|
||||
constexpr auto Mio = mebi<octet>;
|
||||
constexpr auto Gio = gibi<octet>;
|
||||
constexpr auto Tio = tebi<octet>;
|
||||
constexpr auto Pio = pebi<octet>;
|
||||
constexpr auto Eio = exbi<octet>;
|
||||
inline constexpr auto Kio = kibi<octet>;
|
||||
inline constexpr auto Mio = mebi<octet>;
|
||||
inline constexpr auto Gio = gibi<octet>;
|
||||
inline constexpr auto Tio = tebi<octet>;
|
||||
inline constexpr auto Pio = pebi<octet>;
|
||||
inline constexpr auto Eio = exbi<octet>;
|
||||
|
||||
// byte
|
||||
constexpr auto B = byte;
|
||||
inline constexpr auto B = byte;
|
||||
|
||||
constexpr auto kB = si::kilo<byte>;
|
||||
constexpr auto MB = si::mega<byte>;
|
||||
constexpr auto GB = si::giga<byte>;
|
||||
constexpr auto TB = si::tera<byte>;
|
||||
constexpr auto PB = si::peta<byte>;
|
||||
constexpr auto EB = si::exa<byte>;
|
||||
constexpr auto ZB = si::zetta<byte>;
|
||||
constexpr auto YB = si::yotta<byte>;
|
||||
constexpr auto RB = si::ronna<byte>;
|
||||
constexpr auto QB = si::quetta<byte>;
|
||||
inline constexpr auto kB = si::kilo<byte>;
|
||||
inline constexpr auto MB = si::mega<byte>;
|
||||
inline constexpr auto GB = si::giga<byte>;
|
||||
inline constexpr auto TB = si::tera<byte>;
|
||||
inline constexpr auto PB = si::peta<byte>;
|
||||
inline constexpr auto EB = si::exa<byte>;
|
||||
inline constexpr auto ZB = si::zetta<byte>;
|
||||
inline constexpr auto YB = si::yotta<byte>;
|
||||
inline constexpr auto RB = si::ronna<byte>;
|
||||
inline constexpr auto QB = si::quetta<byte>;
|
||||
|
||||
constexpr auto KiB = kibi<byte>;
|
||||
constexpr auto MiB = mebi<byte>;
|
||||
constexpr auto GiB = gibi<byte>;
|
||||
constexpr auto TiB = tebi<byte>;
|
||||
constexpr auto PiB = pebi<byte>;
|
||||
constexpr auto EiB = exbi<byte>;
|
||||
inline constexpr auto KiB = kibi<byte>;
|
||||
inline constexpr auto MiB = mebi<byte>;
|
||||
inline constexpr auto GiB = gibi<byte>;
|
||||
inline constexpr auto TiB = tebi<byte>;
|
||||
inline constexpr auto PiB = pebi<byte>;
|
||||
inline constexpr auto EiB = exbi<byte>;
|
||||
|
||||
// baud
|
||||
constexpr auto Bd = baud;
|
||||
constexpr auto kBd = si::kilo<baud>;
|
||||
constexpr auto MBd = si::mega<baud>;
|
||||
constexpr auto GBd = si::giga<baud>;
|
||||
constexpr auto TBd = si::tera<baud>;
|
||||
constexpr auto PBd = si::peta<baud>;
|
||||
constexpr auto EBd = si::exa<baud>;
|
||||
constexpr auto ZBd = si::zetta<baud>;
|
||||
constexpr auto YBd = si::yotta<baud>;
|
||||
constexpr auto RBd = si::ronna<baud>;
|
||||
constexpr auto QBd = si::quetta<baud>;
|
||||
inline constexpr auto Bd = baud;
|
||||
inline constexpr auto kBd = si::kilo<baud>;
|
||||
inline constexpr auto MBd = si::mega<baud>;
|
||||
inline constexpr auto GBd = si::giga<baud>;
|
||||
inline constexpr auto TBd = si::tera<baud>;
|
||||
inline constexpr auto PBd = si::peta<baud>;
|
||||
inline constexpr auto EBd = si::exa<baud>;
|
||||
inline constexpr auto ZBd = si::zetta<baud>;
|
||||
inline constexpr auto YBd = si::yotta<baud>;
|
||||
inline constexpr auto RBd = si::ronna<baud>;
|
||||
inline constexpr auto QBd = si::quetta<baud>;
|
||||
|
||||
// erlang
|
||||
// TODO do we need prefixed versions of Erlang?
|
||||
constexpr auto E = erlang;
|
||||
inline constexpr auto E = erlang;
|
||||
|
||||
} // namespace mp_units::iec80000::unit_symbols
|
||||
|
@ -34,11 +34,11 @@ MP_UNITS_EXPORT
|
||||
namespace mp_units::iec80000 {
|
||||
|
||||
// clang-format off
|
||||
constexpr struct erlang final : named_unit<"E", kind_of<traffic_intensity>> {} erlang;
|
||||
constexpr struct bit final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
constexpr struct octet final : named_unit<"o", mag<8> * bit> {} octet;
|
||||
constexpr struct byte final : named_unit<"B", mag<8> * bit> {} byte;
|
||||
constexpr struct baud final : named_unit<"Bd", one / si::second, kind_of<modulation_rate>> {} baud;
|
||||
inline 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;
|
||||
inline constexpr struct octet final : named_unit<"o", mag<8> * bit> {} octet;
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
} // namespace mp_units::iec80000
|
||||
|
@ -39,67 +39,67 @@ using namespace international;
|
||||
|
||||
// clang-format off
|
||||
// https://en.wikipedia.org/wiki/Imperial_units#Length
|
||||
constexpr struct hand final : named_unit<"hh", mag_ratio<1, 3> * foot> {} hand;
|
||||
constexpr struct barleycorn final : named_unit<"Bc", mag_ratio<1, 3> * inch> {} barleycorn;
|
||||
constexpr struct thou final : named_unit<"th", mag_ratio<1, 12'000> * foot> {} thou;
|
||||
constexpr struct chain final : named_unit<"ch", mag<22> * yard> {} chain;
|
||||
constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
|
||||
|
||||
// maritime units
|
||||
constexpr struct cable final : named_unit<"cb", mag_ratio<1, 10> * nautical_mile> {} cable;
|
||||
constexpr struct fathom final : named_unit<"ftm", mag_ratio<1, 1000> * nautical_mile> {} fathom;
|
||||
inline 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;
|
||||
|
||||
// survey
|
||||
constexpr struct link final : named_unit<"li", mag_ratio<1, 100> * chain> {} link;
|
||||
constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
|
||||
inline 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;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Imperial_units#Area
|
||||
constexpr struct perch final : named_unit<"perch", square(rod)> {} perch;
|
||||
constexpr struct rood final : named_unit<"rood", mag<40> * perch> {} rood;
|
||||
constexpr struct acre final : named_unit<"acre", mag<4> * rood> {} acre;
|
||||
inline constexpr struct perch final : named_unit<"perch", square(rod)> {} perch;
|
||||
inline constexpr struct rood final : named_unit<"rood", mag<40> * perch> {} rood;
|
||||
inline constexpr struct acre final : named_unit<"acre", mag<4> * rood> {} acre;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Imperial_units#Volume
|
||||
constexpr struct gallon final : named_unit<"gal", mag_ratio<454'609, 100'000> * si::litre> {} gallon;
|
||||
constexpr struct quart final : named_unit<"qt", mag_ratio<1, 4> * gallon> {} quart;
|
||||
constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint;
|
||||
constexpr struct gill final : named_unit<"gi", mag_ratio<1, 4> * pint> {} gill;
|
||||
constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 5> * gill> {} fluid_ounce;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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
|
||||
constexpr auto drachm = dram;
|
||||
constexpr struct stone final : named_unit<"st", mag<14> * pound> {} stone;
|
||||
constexpr struct quarter final : named_unit<"qr", mag<2> * stone> {} quarter;
|
||||
constexpr struct long_hundredweight final : named_unit<"cwt", mag<8> * stone> {} long_hundredweight;
|
||||
constexpr struct ton final : named_unit<"t", mag<2'240> * pound> {} ton;
|
||||
constexpr auto long_ton = ton;
|
||||
inline constexpr auto drachm = dram;
|
||||
inline constexpr struct stone final : named_unit<"st", mag<14> * pound> {} stone;
|
||||
inline 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;
|
||||
inline constexpr struct ton final : named_unit<"t", mag<2'240> * pound> {} ton;
|
||||
inline constexpr auto long_ton = ton;
|
||||
// clang-format on
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
using namespace international::unit_symbols;
|
||||
|
||||
constexpr auto hh = hand;
|
||||
constexpr auto Bc = barleycorn;
|
||||
constexpr auto th = thou;
|
||||
constexpr auto ch = chain;
|
||||
constexpr auto fur = furlong;
|
||||
inline constexpr auto hh = hand;
|
||||
inline constexpr auto Bc = barleycorn;
|
||||
inline constexpr auto th = thou;
|
||||
inline constexpr auto ch = chain;
|
||||
inline constexpr auto fur = furlong;
|
||||
|
||||
constexpr auto cb = cable;
|
||||
constexpr auto ftm = fathom;
|
||||
inline constexpr auto cb = cable;
|
||||
inline constexpr auto ftm = fathom;
|
||||
|
||||
constexpr auto li = link;
|
||||
constexpr auto rd = rod;
|
||||
inline constexpr auto li = link;
|
||||
inline constexpr auto rd = rod;
|
||||
|
||||
constexpr auto gal = gallon;
|
||||
constexpr auto qt = quart;
|
||||
constexpr auto pt = pint;
|
||||
constexpr auto gi = gill;
|
||||
constexpr auto fl_oz = fluid_ounce;
|
||||
inline constexpr auto gal = gallon;
|
||||
inline constexpr auto qt = quart;
|
||||
inline constexpr auto pt = pint;
|
||||
inline constexpr auto gi = gill;
|
||||
inline constexpr auto fl_oz = fluid_ounce;
|
||||
|
||||
constexpr auto st = stone;
|
||||
constexpr auto qr = quarter;
|
||||
constexpr auto cwt = long_hundredweight;
|
||||
constexpr auto t = ton;
|
||||
inline constexpr auto st = stone;
|
||||
inline constexpr auto qr = quarter;
|
||||
inline constexpr auto cwt = long_hundredweight;
|
||||
inline constexpr auto t = ton;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -37,72 +37,72 @@ namespace mp_units::international {
|
||||
|
||||
// clang-format off
|
||||
// mass
|
||||
constexpr struct pound final : named_unit<"lb", mag_ratio<45'359'237, 100'000'000> * si::kilogram> {} pound;
|
||||
constexpr struct ounce final : named_unit<"oz", mag_ratio<1, 16> * pound> {} ounce;
|
||||
constexpr struct dram final : named_unit<"dr", mag_ratio<1, 16> * ounce> {} dram;
|
||||
constexpr struct grain final : named_unit<"gr", mag_ratio<1, 7'000> * pound> {} grain;
|
||||
inline 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;
|
||||
inline 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;
|
||||
|
||||
// length
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Length
|
||||
constexpr struct yard final : named_unit<"yd", mag_ratio<9'144, 10'000> * si::metre> {} yard;
|
||||
constexpr struct foot final : named_unit<"ft", mag_ratio<1, 3> * yard> {} foot;
|
||||
constexpr struct inch final : named_unit<"in", mag_ratio<1, 12> * foot> {} inch;
|
||||
constexpr struct pica final : named_unit<"P", mag_ratio<1, 6> * inch> {} pica;
|
||||
constexpr struct point final : named_unit<"p", mag_ratio<1, 12> * pica> {} point;
|
||||
constexpr struct mil final : named_unit<"mil", mag_ratio<1, 1'000> * inch> {} mil;
|
||||
constexpr struct twip final : named_unit<"twip", mag_ratio<1, 20> * point> {} twip;
|
||||
constexpr struct mile final : named_unit<"mi", mag<1760> * yard> {} mile;
|
||||
constexpr struct league final : named_unit<"le", mag<3> * mile> {} league;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct league final : named_unit<"le", mag<3> * mile> {} league;
|
||||
|
||||
constexpr struct nautical_mile final : named_unit<"nmi", mag<1852> * si::metre> {} nautical_mile;
|
||||
inline constexpr struct nautical_mile final : named_unit<"nmi", mag<1852> * si::metre> {} nautical_mile;
|
||||
|
||||
// speed
|
||||
constexpr struct knot final : named_unit<"kn", nautical_mile / si::hour> {} knot;
|
||||
inline constexpr struct knot final : named_unit<"kn", nautical_mile / si::hour> {} knot;
|
||||
|
||||
// force
|
||||
// https://en.wikipedia.org/wiki/Poundal
|
||||
constexpr struct poundal final : named_unit<"pdl", pound * foot / square(si::second)> {} poundal;
|
||||
inline constexpr struct poundal final : named_unit<"pdl", pound * foot / square(si::second)> {} poundal;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Pound_(force)
|
||||
constexpr struct pound_force final : named_unit<"lbf", pound * si::standard_gravity> {} pound_force;
|
||||
inline constexpr struct pound_force final : named_unit<"lbf", pound * si::standard_gravity> {} pound_force;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Kip_(unit),
|
||||
constexpr auto kip = si::kilo<pound_force>;
|
||||
inline constexpr auto kip = si::kilo<pound_force>;
|
||||
|
||||
// pressure
|
||||
constexpr struct psi final : named_unit<"psi", pound_force / square(inch)> {} psi;
|
||||
inline constexpr struct psi final : named_unit<"psi", pound_force / square(inch)> {} psi;
|
||||
|
||||
// power
|
||||
// https://en.wikipedia.org/wiki/Horsepower#Definitions
|
||||
constexpr struct mechanical_horsepower final : named_unit<"hp(I)", mag<33'000> * foot * pound_force / si::minute> {} mechanical_horsepower;
|
||||
inline constexpr struct mechanical_horsepower final : named_unit<"hp(I)", mag<33'000> * foot * pound_force / si::minute> {} mechanical_horsepower;
|
||||
// clang-format on
|
||||
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto lb = pound;
|
||||
constexpr auto oz = ounce;
|
||||
constexpr auto dr = dram;
|
||||
constexpr auto gr = grain;
|
||||
inline constexpr auto lb = pound;
|
||||
inline constexpr auto oz = ounce;
|
||||
inline constexpr auto dr = dram;
|
||||
inline constexpr auto gr = grain;
|
||||
|
||||
constexpr auto yd = yard;
|
||||
constexpr auto ft = foot;
|
||||
constexpr auto in = inch;
|
||||
constexpr auto P = pica;
|
||||
constexpr auto p = point;
|
||||
constexpr auto mi = mile;
|
||||
constexpr auto le = league;
|
||||
inline constexpr auto yd = yard;
|
||||
inline constexpr auto ft = foot;
|
||||
inline constexpr auto in = inch;
|
||||
inline constexpr auto P = pica;
|
||||
inline constexpr auto p = point;
|
||||
inline constexpr auto mi = mile;
|
||||
inline constexpr auto le = league;
|
||||
|
||||
constexpr auto nmi = nautical_mile;
|
||||
inline constexpr auto nmi = nautical_mile;
|
||||
|
||||
constexpr auto kn = knot;
|
||||
constexpr auto kt = knot;
|
||||
constexpr auto mph = mile / si::hour;
|
||||
inline constexpr auto kn = knot;
|
||||
inline constexpr auto kt = knot;
|
||||
inline constexpr auto mph = mile / si::hour;
|
||||
|
||||
constexpr auto pdl = poundal;
|
||||
constexpr auto lbf = pound_force;
|
||||
inline constexpr auto pdl = poundal;
|
||||
inline constexpr auto lbf = pound_force;
|
||||
|
||||
constexpr auto hp = mechanical_horsepower;
|
||||
inline constexpr auto hp = mechanical_horsepower;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -35,20 +35,20 @@ namespace mp_units::isq {
|
||||
|
||||
// clang-format off
|
||||
// dimensions of base quantities
|
||||
constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_electric_current final : base_dimension<"I"> {} dim_electric_current;
|
||||
constexpr struct dim_thermodynamic_temperature final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
|
||||
constexpr struct dim_amount_of_substance final : base_dimension<"N"> {} dim_amount_of_substance;
|
||||
constexpr struct dim_luminous_intensity final : base_dimension<"J"> {} dim_luminous_intensity;
|
||||
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time final : base_dimension<"T"> {} dim_time;
|
||||
inline 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;
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
// base quantities
|
||||
QUANTITY_SPEC(length, dim_length);
|
||||
QUANTITY_SPEC(mass, dim_mass);
|
||||
QUANTITY_SPEC(time, dim_time);
|
||||
constexpr auto duration = time;
|
||||
inline constexpr auto duration = time;
|
||||
QUANTITY_SPEC(electric_current, dim_electric_current);
|
||||
QUANTITY_SPEC(thermodynamic_temperature, dim_thermodynamic_temperature);
|
||||
QUANTITY_SPEC(amount_of_substance, dim_amount_of_substance);
|
||||
|
@ -39,25 +39,25 @@ namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(electric_charge, electric_current* time);
|
||||
QUANTITY_SPEC(electric_charge_density, electric_charge / volume);
|
||||
constexpr auto volume_electric_charge = electric_charge_density;
|
||||
inline constexpr auto volume_electric_charge = electric_charge_density;
|
||||
QUANTITY_SPEC(surface_density_of_electric_charge, electric_charge / area);
|
||||
constexpr auto areic_electric_charge = surface_density_of_electric_charge;
|
||||
inline constexpr auto areic_electric_charge = surface_density_of_electric_charge;
|
||||
QUANTITY_SPEC(linear_density_of_electric_charge, electric_charge / length);
|
||||
constexpr auto lineic_electric_charge = linear_density_of_electric_charge;
|
||||
inline constexpr auto lineic_electric_charge = linear_density_of_electric_charge;
|
||||
QUANTITY_SPEC(electric_dipole_moment, electric_charge* position_vector); // vector
|
||||
QUANTITY_SPEC(electric_polarization, electric_dipole_moment / volume); // vector
|
||||
QUANTITY_SPEC(electric_current_density, electric_charge_density* velocity); // vector
|
||||
constexpr auto areic_electric_current = electric_current_density;
|
||||
inline constexpr auto areic_electric_current = electric_current_density;
|
||||
QUANTITY_SPEC(linear_electric_current_density, surface_density_of_electric_charge* velocity); // vector
|
||||
constexpr auto lineic_electric_current = linear_electric_current_density;
|
||||
inline constexpr auto lineic_electric_current = linear_electric_current_density;
|
||||
QUANTITY_SPEC(electric_field_strength, force / electric_charge); // vector
|
||||
QUANTITY_SPEC(electric_potential, electric_field_strength* length,
|
||||
quantity_character::scalar); // TODO what is a correct equation here?
|
||||
QUANTITY_SPEC(electric_potential_difference, electric_potential, quantity_character::scalar);
|
||||
QUANTITY_SPEC(voltage, electric_potential);
|
||||
constexpr auto electric_tension = voltage;
|
||||
inline constexpr auto electric_tension = voltage;
|
||||
QUANTITY_SPEC(electric_flux_density, electric_polarization); // vector
|
||||
constexpr auto electric_displacement = electric_flux_density;
|
||||
inline constexpr auto electric_displacement = electric_flux_density;
|
||||
QUANTITY_SPEC(capacitance, electric_charge / voltage);
|
||||
// TODO how to calculate an argument of a vector product?
|
||||
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(magnetic_constant,
|
||||
electric_potential* time / (electric_current * length)); // TODO what is a correct equation here?
|
||||
constexpr auto permeability_of_vacuum = magnetic_constant;
|
||||
inline constexpr auto permeability_of_vacuum = magnetic_constant;
|
||||
QUANTITY_SPEC(phase_speed_of_electromagnetic_waves, angular_frequency / angular_wavenumber);
|
||||
QUANTITY_SPEC(speed_of_light_in_vacuum, speed);
|
||||
constexpr auto light_speed_in_vacuum = speed_of_light_in_vacuum;
|
||||
constexpr auto luminal_speed = speed_of_light_in_vacuum;
|
||||
inline constexpr auto light_speed_in_vacuum = speed_of_light_in_vacuum;
|
||||
inline constexpr auto luminal_speed = speed_of_light_in_vacuum;
|
||||
QUANTITY_SPEC(electric_constant, inverse(magnetic_constant* pow<2>(speed_of_light_in_vacuum)));
|
||||
constexpr auto permittivity_of_vacuum = electric_constant;
|
||||
inline constexpr auto permittivity_of_vacuum = electric_constant;
|
||||
QUANTITY_SPEC(permittivity, electric_flux_density / electric_field_strength, quantity_character::scalar);
|
||||
QUANTITY_SPEC(relative_permittivity, dimensionless, permittivity / electric_constant);
|
||||
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(magnetic_flux, magnetic_flux_density* area, quantity_character::scalar);
|
||||
QUANTITY_SPEC(magnetic_moment, electric_current* area, quantity_character::vector);
|
||||
constexpr auto magnetic_area_moment = magnetic_moment;
|
||||
inline constexpr auto magnetic_area_moment = magnetic_moment;
|
||||
QUANTITY_SPEC(magnetization, magnetic_moment / volume); // vector
|
||||
QUANTITY_SPEC(magnetic_field_strength, magnetization); // vector
|
||||
constexpr auto magnetizing_field = magnetic_field_strength;
|
||||
inline constexpr auto magnetizing_field = magnetic_field_strength;
|
||||
QUANTITY_SPEC(permeability, magnetic_flux_density / magnetic_field_strength, quantity_character::scalar);
|
||||
QUANTITY_SPEC(relative_permeability, dimensionless, permeability / magnetic_constant);
|
||||
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(electromagnetic_energy_density, electric_field_strength* electric_flux_density,
|
||||
quantity_character::scalar);
|
||||
constexpr auto volumic_electromagnetic_energy = electromagnetic_energy_density;
|
||||
inline constexpr auto volumic_electromagnetic_energy = electromagnetic_energy_density;
|
||||
QUANTITY_SPEC(Poynting_vector, electric_field_strength* magnetic_field_strength); // vector
|
||||
QUANTITY_SPEC(source_voltage, voltage);
|
||||
constexpr auto source_tension = source_voltage;
|
||||
inline constexpr auto source_tension = source_voltage;
|
||||
QUANTITY_SPEC(scalar_magnetic_potential, electric_current, magnetic_field_strength* length,
|
||||
quantity_character::scalar); // TODO what is a correct equation here?
|
||||
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(permeance, inverse(reluctance));
|
||||
QUANTITY_SPEC(inductance, linked_flux / electric_current);
|
||||
constexpr auto self_inductance = inductance;
|
||||
inline constexpr auto self_inductance = inductance;
|
||||
QUANTITY_SPEC(mutual_inductance, linked_flux / electric_current);
|
||||
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(conductivity, electric_current_density / electric_field_strength, quantity_character::scalar);
|
||||
QUANTITY_SPEC(resistivity, inverse(conductivity));
|
||||
QUANTITY_SPEC(electromagnetism_power, power, voltage* electric_current);
|
||||
constexpr auto instantaneous_power = electromagnetism_power;
|
||||
inline constexpr auto instantaneous_power = electromagnetism_power;
|
||||
QUANTITY_SPEC(resistance, voltage / electric_current);
|
||||
QUANTITY_SPEC(conductance, inverse(resistance));
|
||||
QUANTITY_SPEC(phase_difference, phase_angle);
|
||||
QUANTITY_SPEC(electric_current_phasor, electric_current);
|
||||
QUANTITY_SPEC(voltage_phasor, voltage);
|
||||
QUANTITY_SPEC(impedance, voltage_phasor / electric_current_phasor);
|
||||
constexpr auto complex_impedance = impedance;
|
||||
inline constexpr auto complex_impedance = impedance;
|
||||
QUANTITY_SPEC(resistance_to_alternating_current, impedance);
|
||||
QUANTITY_SPEC(reactance, impedance);
|
||||
QUANTITY_SPEC(modulus_of_impedance, impedance);
|
||||
QUANTITY_SPEC(admittance, inverse(impedance));
|
||||
constexpr auto complex_admittance = admittance;
|
||||
inline constexpr auto complex_admittance = admittance;
|
||||
QUANTITY_SPEC(conductance_for_alternating_current, admittance);
|
||||
QUANTITY_SPEC(susceptance, admittance);
|
||||
QUANTITY_SPEC(modulus_of_admittance, admittance);
|
||||
|
@ -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_wavenumber, radiant_energy_density / wavenumber);
|
||||
QUANTITY_SPEC(radiant_flux, power, radiant_energy / time);
|
||||
constexpr auto radiant_power = radiant_flux;
|
||||
inline constexpr auto radiant_power = radiant_flux;
|
||||
QUANTITY_SPEC(spectral_radiant_flux, radiant_flux / wavelength);
|
||||
constexpr auto spectral_radiant_power = spectral_radiant_flux;
|
||||
inline constexpr auto spectral_radiant_power = spectral_radiant_flux;
|
||||
QUANTITY_SPEC(radiant_intensity, radiant_flux / solid_angular_measure);
|
||||
QUANTITY_SPEC(spectral_radiant_intensity, radiant_intensity / wavelength);
|
||||
QUANTITY_SPEC(radiance, radiant_intensity / area);
|
||||
|
@ -37,24 +37,24 @@ MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(mass_density, mass / volume);
|
||||
constexpr auto density = mass_density;
|
||||
inline constexpr auto density = mass_density;
|
||||
QUANTITY_SPEC(specific_volume, inverse(mass_density));
|
||||
QUANTITY_SPEC(relative_mass_density, mass_density / mass_density);
|
||||
constexpr auto relative_density = relative_mass_density;
|
||||
inline constexpr auto relative_density = relative_mass_density;
|
||||
QUANTITY_SPEC(surface_mass_density, mass / area);
|
||||
constexpr auto surface_density = surface_mass_density;
|
||||
inline constexpr auto surface_density = surface_mass_density;
|
||||
QUANTITY_SPEC(linear_mass_density, mass / length);
|
||||
constexpr auto linear_density = linear_mass_density;
|
||||
inline constexpr auto linear_density = linear_mass_density;
|
||||
QUANTITY_SPEC(momentum, mass* velocity); // vector
|
||||
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(static_friction_force, force); // vector
|
||||
constexpr auto static_friction = static_friction_force;
|
||||
inline constexpr auto static_friction = static_friction_force;
|
||||
QUANTITY_SPEC(kinetic_friction_force, force); // vector
|
||||
constexpr auto dynamic_friction_force = kinetic_friction_force;
|
||||
inline constexpr auto dynamic_friction_force = kinetic_friction_force;
|
||||
QUANTITY_SPEC(rolling_resistance, force); // vector
|
||||
constexpr auto rolling_drag = rolling_resistance;
|
||||
constexpr auto rolling_friction_force = rolling_resistance;
|
||||
inline constexpr auto rolling_drag = rolling_resistance;
|
||||
inline constexpr auto rolling_friction_force = rolling_resistance;
|
||||
QUANTITY_SPEC(drag_force, force); // vector
|
||||
QUANTITY_SPEC(impulse, force* time); // 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(Poisson_number, dimensionless, width / length);
|
||||
QUANTITY_SPEC(modulus_of_elasticity, normal_stress / relative_linear_strain);
|
||||
constexpr auto Young_modulus = modulus_of_elasticity;
|
||||
inline constexpr auto Young_modulus = modulus_of_elasticity;
|
||||
QUANTITY_SPEC(modulus_of_rigidity, shear_stress / shear_strain);
|
||||
constexpr auto shear_modulus = modulus_of_rigidity;
|
||||
inline constexpr auto shear_modulus = modulus_of_rigidity;
|
||||
QUANTITY_SPEC(modulus_of_compression, pressure / relative_volume_strain);
|
||||
constexpr auto bulk_modulus = modulus_of_compression;
|
||||
inline constexpr auto bulk_modulus = modulus_of_compression;
|
||||
QUANTITY_SPEC(compressibility, inverse(volume) * (volume / pressure));
|
||||
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(section_modulus, second_axial_moment_of_area / radial_distance);
|
||||
QUANTITY_SPEC(static_friction_coefficient, dimensionless, static_friction_force / force, quantity_character::scalar);
|
||||
constexpr auto static_friction_factor = static_friction_coefficient;
|
||||
constexpr auto coefficient_of_static_friction = static_friction_coefficient;
|
||||
inline constexpr auto static_friction_factor = static_friction_coefficient;
|
||||
inline constexpr auto coefficient_of_static_friction = static_friction_coefficient;
|
||||
QUANTITY_SPEC(kinetic_friction_factor, dimensionless, kinetic_friction_force / force, quantity_character::scalar);
|
||||
constexpr auto dynamic_friction_factor = kinetic_friction_factor;
|
||||
inline constexpr auto dynamic_friction_factor = kinetic_friction_factor;
|
||||
QUANTITY_SPEC(rolling_resistance_factor, force / force, quantity_character::scalar);
|
||||
QUANTITY_SPEC(drag_coefficient, dimensionless, drag_force / (mass_density * pow<2>(speed) * area),
|
||||
quantity_character::scalar);
|
||||
constexpr auto drag_factor = drag_coefficient;
|
||||
inline constexpr auto drag_factor = drag_coefficient;
|
||||
QUANTITY_SPEC(dynamic_viscosity, shear_stress* length / velocity, quantity_character::scalar);
|
||||
QUANTITY_SPEC(kinematic_viscosity, dynamic_viscosity / mass_density);
|
||||
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(kinetic_energy, mechanical_energy, mass* pow<2>(speed)); // differs from ISO 80000
|
||||
QUANTITY_SPEC(mechanical_work, force* displacement, quantity_character::scalar);
|
||||
constexpr auto work = mechanical_work;
|
||||
inline constexpr auto work = mechanical_work;
|
||||
QUANTITY_SPEC(mechanical_efficiency, mechanical_power / mechanical_power);
|
||||
QUANTITY_SPEC(mass_flow, mass_density* velocity); // vector
|
||||
QUANTITY_SPEC(mass_flow_rate, mass_flow* area, quantity_character::scalar);
|
||||
|
@ -37,15 +37,15 @@ namespace mp_units::isq {
|
||||
|
||||
// space and time
|
||||
QUANTITY_SPEC(width, length);
|
||||
constexpr auto breadth = width;
|
||||
inline constexpr auto breadth = width;
|
||||
QUANTITY_SPEC(radius, width); // differs from ISO 80000
|
||||
QUANTITY_SPEC(path_length, length);
|
||||
constexpr auto arc_length = path_length;
|
||||
inline constexpr auto arc_length = path_length;
|
||||
QUANTITY_SPEC(area, pow<2>(length));
|
||||
QUANTITY_SPEC(angular_measure, dimensionless, arc_length / radius, is_kind);
|
||||
QUANTITY_SPEC(solid_angular_measure, dimensionless, area / pow<2>(radius), is_kind);
|
||||
QUANTITY_SPEC(period_duration, duration);
|
||||
constexpr auto period = period_duration;
|
||||
inline constexpr auto period = period_duration;
|
||||
QUANTITY_SPEC(frequency, inverse(period_duration));
|
||||
|
||||
// mechanics
|
||||
|
@ -36,8 +36,8 @@ MP_UNITS_EXPORT
|
||||
namespace mp_units::isq {
|
||||
|
||||
QUANTITY_SPEC(height, length);
|
||||
constexpr auto depth = height;
|
||||
constexpr auto altitude = height;
|
||||
inline constexpr auto depth = height;
|
||||
inline constexpr auto altitude = height;
|
||||
QUANTITY_SPEC(thickness, width);
|
||||
QUANTITY_SPEC(diameter, width);
|
||||
QUANTITY_SPEC(distance, path_length);
|
||||
@ -48,7 +48,7 @@ QUANTITY_SPEC(radius_of_curvature, radius);
|
||||
QUANTITY_SPEC(curvature, inverse(radius_of_curvature));
|
||||
QUANTITY_SPEC(volume, pow<3>(length));
|
||||
QUANTITY_SPEC(rotational_displacement, angular_measure, path_length / radius);
|
||||
constexpr auto angular_displacement = rotational_displacement;
|
||||
inline constexpr auto angular_displacement = rotational_displacement;
|
||||
QUANTITY_SPEC(phase_angle, angular_measure);
|
||||
QUANTITY_SPEC(speed, length / time); // 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(wavelength, length);
|
||||
QUANTITY_SPEC(repetency, inverse(wavelength));
|
||||
constexpr auto wavenumber = repetency;
|
||||
inline constexpr auto wavenumber = repetency;
|
||||
QUANTITY_SPEC(wave_vector, repetency, quantity_character::vector);
|
||||
QUANTITY_SPEC(angular_repetency, inverse(wavelength));
|
||||
constexpr auto angular_wavenumber = angular_repetency;
|
||||
inline constexpr auto angular_wavenumber = angular_repetency;
|
||||
QUANTITY_SPEC(phase_velocity, angular_frequency / angular_repetency);
|
||||
constexpr auto phase_speed = phase_velocity;
|
||||
inline constexpr auto phase_speed = phase_velocity;
|
||||
QUANTITY_SPEC(group_velocity, angular_frequency / angular_repetency);
|
||||
constexpr auto group_speed = group_velocity;
|
||||
inline constexpr auto group_speed = group_velocity;
|
||||
QUANTITY_SPEC(damping_coefficient, inverse(time_constant));
|
||||
QUANTITY_SPEC(logarithmic_decrement, dimensionless, damping_coefficient* period_duration);
|
||||
QUANTITY_SPEC(attenuation, inverse(distance));
|
||||
constexpr auto extinction = attenuation;
|
||||
inline constexpr auto extinction = attenuation;
|
||||
QUANTITY_SPEC(phase_coefficient, phase_angle / path_length);
|
||||
QUANTITY_SPEC(propagation_coefficient, inverse(length)); // γ = α + iβ where α denotes attenuation
|
||||
// and β the phase coefficient of a plane wave
|
||||
|
@ -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
|
||||
// energy definition moved to mechanics
|
||||
QUANTITY_SPEC(heat, energy);
|
||||
constexpr auto amount_of_heat = heat;
|
||||
inline constexpr auto amount_of_heat = heat;
|
||||
QUANTITY_SPEC(latent_heat, heat); // TODO what is a correct equation here?
|
||||
QUANTITY_SPEC(heat_flow_rate, heat / time);
|
||||
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(surface_coefficient_of_heat_transfer, density_of_heat_flow_rate / thermodynamic_temperature);
|
||||
QUANTITY_SPEC(thermal_insulance, inverse(coefficient_of_heat_transfer));
|
||||
constexpr auto coefficient_of_thermal_insulance = thermal_insulance;
|
||||
inline constexpr auto coefficient_of_thermal_insulance = thermal_insulance;
|
||||
QUANTITY_SPEC(thermal_resistance, thermodynamic_temperature / heat_flow_rate);
|
||||
QUANTITY_SPEC(thermal_conductance, inverse(thermal_resistance));
|
||||
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);
|
||||
QUANTITY_SPEC(isentropic_exponent,
|
||||
volume / pressure * (pressure / volume)); // TODO how to handle "negative" part
|
||||
constexpr auto isentropic_expansion_factor = isentropic_exponent;
|
||||
inline constexpr auto isentropic_expansion_factor = isentropic_exponent;
|
||||
QUANTITY_SPEC(entropy, kinetic_energy / thermodynamic_temperature);
|
||||
QUANTITY_SPEC(specific_entropy, entropy / mass);
|
||||
QUANTITY_SPEC(enthalpy, energy); // differs from ISO 80000
|
||||
QUANTITY_SPEC(internal_energy, enthalpy); // differs from ISO 80000
|
||||
constexpr auto thermodynamic_energy = internal_energy;
|
||||
inline constexpr auto thermodynamic_energy = internal_energy;
|
||||
QUANTITY_SPEC(Helmholtz_energy, internal_energy);
|
||||
constexpr auto Helmholtz_function = Helmholtz_energy;
|
||||
inline constexpr auto Helmholtz_function = Helmholtz_energy;
|
||||
QUANTITY_SPEC(Gibbs_energy, enthalpy);
|
||||
constexpr auto Gibbs_function = Gibbs_energy;
|
||||
inline constexpr auto Gibbs_function = Gibbs_energy;
|
||||
QUANTITY_SPEC(specific_energy, energy / mass);
|
||||
QUANTITY_SPEC(specific_internal_energy, internal_energy / mass);
|
||||
constexpr auto specific_thermodynamic_energy = specific_internal_energy;
|
||||
inline constexpr auto specific_thermodynamic_energy = specific_internal_energy;
|
||||
QUANTITY_SPEC(specific_enthalpy, enthalpy / mass);
|
||||
QUANTITY_SPEC(specific_Helmholtz_energy, Helmholtz_energy / mass);
|
||||
constexpr auto specific_Helmholtz_function = specific_Helmholtz_energy;
|
||||
inline constexpr auto specific_Helmholtz_function = specific_Helmholtz_energy;
|
||||
QUANTITY_SPEC(specific_Gibbs_energy, Gibbs_energy / mass);
|
||||
constexpr auto specific_Gibbs_function = specific_Gibbs_energy;
|
||||
inline constexpr auto specific_Gibbs_function = specific_Gibbs_energy;
|
||||
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(Joule_Thomson_coefficient, thermodynamic_temperature / pressure);
|
||||
|
@ -43,7 +43,7 @@ using namespace isq;
|
||||
QUANTITY_SPEC(cotes_angle_constant, angular::angle); // 1 rad
|
||||
QUANTITY_SPEC(angular_measure, angular::angle, cotes_angle_constant* arc_length / radius);
|
||||
QUANTITY_SPEC(rotational_displacement, angular::angle, cotes_angle_constant* path_length / radius);
|
||||
constexpr auto angular_displacement = rotational_displacement;
|
||||
inline constexpr auto angular_displacement = rotational_displacement;
|
||||
QUANTITY_SPEC(phase_angle, angular_measure);
|
||||
QUANTITY_SPEC(solid_angular_measure, pow<2>(cotes_angle_constant) * area / pow<2>(radius));
|
||||
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(angular_frequency, phase_angle / duration);
|
||||
QUANTITY_SPEC(angular_repetency, cotes_angle_constant / wavelength);
|
||||
constexpr auto angular_wavenumber = angular_repetency;
|
||||
inline constexpr auto angular_wavenumber = angular_repetency;
|
||||
QUANTITY_SPEC(phase_coefficient, phase_angle / path_length);
|
||||
QUANTITY_SPEC(propagation_coefficient, cotes_angle_constant / length);
|
||||
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);
|
||||
|
||||
// constants
|
||||
constexpr auto cotes_angle = cotes_angle_constant[angular::radian];
|
||||
inline constexpr auto cotes_angle = cotes_angle_constant[angular::radian];
|
||||
|
||||
} // namespace mp_units::isq_angle
|
||||
|
@ -38,28 +38,28 @@ namespace mp_units::natural {
|
||||
|
||||
// clang-format off
|
||||
// units
|
||||
constexpr struct electronvolt final : named_unit<"eV"> {} electronvolt;
|
||||
constexpr auto gigaelectronvolt = si::giga<electronvolt>;
|
||||
inline constexpr struct electronvolt final : named_unit<"eV"> {} electronvolt;
|
||||
inline constexpr auto gigaelectronvolt = si::giga<electronvolt>;
|
||||
|
||||
// system references
|
||||
constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time;
|
||||
constexpr struct length : system_reference<isq::length, inverse(gigaelectronvolt)> {} length;
|
||||
constexpr struct mass : system_reference<isq::mass, gigaelectronvolt> {} mass;
|
||||
constexpr struct velocity : system_reference<isq::velocity, one> {} velocity;
|
||||
constexpr struct speed : system_reference<isq::speed, one> {} speed;
|
||||
constexpr struct acceleration : system_reference<isq::acceleration, gigaelectronvolt> {} acceleration;
|
||||
constexpr struct momentum : system_reference<isq::momentum, gigaelectronvolt> {} momentum;
|
||||
constexpr struct force : system_reference<isq::force, square(gigaelectronvolt)> {} force;
|
||||
constexpr struct energy : system_reference<isq::mechanical_energy, gigaelectronvolt> {} energy;
|
||||
inline constexpr struct time : system_reference<isq::time, inverse(gigaelectronvolt)> {} time;
|
||||
inline constexpr struct length : system_reference<isq::length, inverse(gigaelectronvolt)> {} length;
|
||||
inline constexpr struct mass : system_reference<isq::mass, gigaelectronvolt> {} mass;
|
||||
inline constexpr struct velocity : system_reference<isq::velocity, one> {} velocity;
|
||||
inline constexpr struct speed : system_reference<isq::speed, one> {} speed;
|
||||
inline constexpr struct acceleration : system_reference<isq::acceleration, gigaelectronvolt> {} acceleration;
|
||||
inline constexpr struct momentum : system_reference<isq::momentum, gigaelectronvolt> {} momentum;
|
||||
inline constexpr struct force : system_reference<isq::force, square(gigaelectronvolt)> {} force;
|
||||
inline constexpr struct energy : system_reference<isq::mechanical_energy, gigaelectronvolt> {} energy;
|
||||
// clang-format on
|
||||
|
||||
// constants
|
||||
constexpr auto speed_of_light = speed[one];
|
||||
inline constexpr auto speed_of_light = speed[one];
|
||||
|
||||
namespace unit_symbols {
|
||||
|
||||
constexpr auto GeV = gigaelectronvolt;
|
||||
constexpr auto GeV2 = square(gigaelectronvolt);
|
||||
inline constexpr auto GeV = gigaelectronvolt;
|
||||
inline constexpr auto GeV2 = square(gigaelectronvolt);
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -35,28 +35,28 @@ namespace mp_units::si {
|
||||
namespace si2019 {
|
||||
|
||||
// clang-format off
|
||||
constexpr struct hyperfine_structure_transition_frequency_of_cs final :
|
||||
inline 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;
|
||||
constexpr struct speed_of_light_in_vacuum final :
|
||||
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 planck_constant final :
|
||||
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 elementary_charge final :
|
||||
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 boltzmann_constant final :
|
||||
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 avogadro_constant final :
|
||||
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 luminous_efficacy final :
|
||||
inline constexpr struct luminous_efficacy final :
|
||||
named_unit<"K_cd", mag<683> * lumen / watt> {} luminous_efficacy;
|
||||
// clang-format on
|
||||
|
||||
} // namespace si2019
|
||||
|
||||
// clang-format off
|
||||
constexpr struct standard_gravity final :
|
||||
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 magnetic_constant final :
|
||||
inline constexpr struct magnetic_constant final :
|
||||
named_unit<symbol_text{u8"μ₀", "u_0"}, mag<4> * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant;
|
||||
// clang-format on
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,55 +39,55 @@ namespace si {
|
||||
|
||||
// clang-format off
|
||||
// base units
|
||||
constexpr struct second final : named_unit<"s", kind_of<isq::time>> {} second;
|
||||
constexpr struct metre final : named_unit<"m", kind_of<isq::length>> {} metre;
|
||||
constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
constexpr auto kilogram = kilo<gram>;
|
||||
constexpr struct ampere final : named_unit<"A", kind_of<isq::electric_current>> {} ampere;
|
||||
inline 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;
|
||||
inline constexpr struct gram final : named_unit<"g", kind_of<isq::mass>> {} gram;
|
||||
inline constexpr auto kilogram = kilo<gram>;
|
||||
inline constexpr struct ampere final : named_unit<"A", kind_of<isq::electric_current>> {} ampere;
|
||||
|
||||
constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
constexpr auto zeroth_kelvin = absolute_zero;
|
||||
constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
inline constexpr struct absolute_zero final : absolute_point_origin<isq::thermodynamic_temperature> {} absolute_zero;
|
||||
inline constexpr auto zeroth_kelvin = absolute_zero;
|
||||
inline constexpr struct kelvin final : named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
|
||||
|
||||
constexpr struct mole final : named_unit<"mol", kind_of<isq::amount_of_substance>> {} mole;
|
||||
constexpr struct candela final : named_unit<"cd", kind_of<isq::luminous_intensity>> {} candela;
|
||||
inline 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;
|
||||
|
||||
// derived named units
|
||||
constexpr struct radian final : named_unit<"rad", metre / metre, kind_of<isq::angular_measure>> {} radian;
|
||||
constexpr struct steradian final : named_unit<"sr", square(metre) / square(metre), kind_of<isq::solid_angular_measure>> {} steradian;
|
||||
constexpr struct hertz final : named_unit<"Hz", one / second, kind_of<isq::frequency>> {} hertz;
|
||||
constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline 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;
|
||||
inline 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;
|
||||
#ifdef pascal
|
||||
#pragma push_macro("pascal")
|
||||
#undef pascal
|
||||
#define MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct pascal final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
#ifdef MP_UNITS_REDEFINE_PASCAL
|
||||
#pragma pop_macro("pascal")
|
||||
#undef MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
|
||||
constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
|
||||
constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
|
||||
constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
constexpr struct siemens final : named_unit<"S", one / ohm> {} siemens;
|
||||
constexpr struct weber final : named_unit<"Wb", volt * second> {} weber;
|
||||
constexpr struct tesla final : named_unit<"T", weber / square(metre)> {} tesla;
|
||||
constexpr struct henry final : named_unit<"H", weber / ampere> {} henry;
|
||||
inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt final : named_unit<"W", joule / second> {} watt;
|
||||
inline constexpr struct coulomb final : named_unit<"C", ampere * second> {} coulomb;
|
||||
inline constexpr struct volt final : named_unit<"V", watt / ampere> {} volt;
|
||||
inline constexpr struct farad final : named_unit<"F", coulomb / volt> {} farad;
|
||||
inline constexpr struct ohm final : named_unit<symbol_text{u8"Ω", "ohm"}, volt / ampere> {} ohm;
|
||||
inline constexpr struct siemens final : named_unit<"S", one / ohm> {} siemens;
|
||||
inline constexpr struct weber final : named_unit<"Wb", volt * second> {} weber;
|
||||
inline constexpr struct tesla final : named_unit<"T", weber / square(metre)> {} tesla;
|
||||
inline constexpr struct henry final : named_unit<"H", weber / ampere> {} henry;
|
||||
|
||||
constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
|
||||
constexpr auto zeroth_degree_Celsius = ice_point;
|
||||
constexpr struct degree_Celsius final : named_unit<symbol_text{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
|
||||
inline constexpr struct ice_point final : relative_point_origin<absolute<milli<kelvin>>(273'150)> {} ice_point;
|
||||
inline 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 lumen final : named_unit<"lm", candela * steradian> {} lumen;
|
||||
constexpr struct lux final : named_unit<"lx", lumen / square(metre)> {} lux;
|
||||
constexpr struct becquerel final : named_unit<"Bq", one / second, kind_of<isq::activity>> {} becquerel;
|
||||
constexpr struct gray final : named_unit<"Gy", joule / kilogram, kind_of<isq::absorbed_dose>> {} gray;
|
||||
constexpr struct sievert final : named_unit<"Sv", joule / kilogram, kind_of<isq::dose_equivalent>> {} sievert;
|
||||
constexpr struct katal final : named_unit<"kat", mole / second> {} katal;
|
||||
inline constexpr struct lumen final : named_unit<"lm", candela * steradian> {} lumen;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct katal final : named_unit<"kat", mole / second> {} katal;
|
||||
// clang-format on
|
||||
|
||||
} // namespace si
|
||||
@ -96,20 +96,20 @@ namespace non_si {
|
||||
|
||||
// clang-format off
|
||||
// non-SI units accepted for use with the SI
|
||||
constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
|
||||
constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr struct day final : named_unit<"d", mag<24> * hour> {} day;
|
||||
constexpr struct astronomical_unit final : named_unit<"au", mag<149'597'870'700> * si::metre> {} astronomical_unit;
|
||||
constexpr struct degree final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * si::radian> {} degree;
|
||||
constexpr struct arcminute final : named_unit<symbol_text{u8"′", "'"}, mag_ratio<1, 60> * degree> {} arcminute;
|
||||
constexpr struct arcsecond final : named_unit<symbol_text{u8"″", "''"}, mag_ratio<1, 60> * arcminute> {} arcsecond;
|
||||
constexpr struct are final : named_unit<"a", square(si::deca<si::metre>)> {} are;
|
||||
constexpr auto hectare = si::hecto<are>;
|
||||
constexpr struct litre final : named_unit<"l", cubic(si::deci<si::metre>)> {} litre;
|
||||
constexpr struct tonne final : named_unit<"t", mag<1000> * si::kilogram> {} tonne;
|
||||
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;
|
||||
inline constexpr struct minute final : named_unit<"min", mag<60> * si::second> {} minute;
|
||||
inline constexpr struct hour final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr auto hectare = si::hecto<are>;
|
||||
inline 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;
|
||||
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;
|
||||
// TODO A different value is provided in the SI Brochure and different in the ISO 80000
|
||||
constexpr struct electronvolt final : named_unit<"eV", mag_ratio<1'602'176'634, 1'000'000'000> * mag_power<10, -19> * si::joule> {} electronvolt;
|
||||
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;
|
||||
// TODO the below are logarithmic units - how to support those?
|
||||
// neper
|
||||
// bel
|
||||
|
@ -36,11 +36,11 @@ namespace mp_units::typographic {
|
||||
|
||||
// clang-format off
|
||||
// https://en.wikipedia.org/wiki/Point_(typography)
|
||||
constexpr struct pica_us final : named_unit<"pica(us)", mag_ratio<166'044, 1'000'000> * international::inch> {} pica_us;
|
||||
constexpr struct point_us final : named_unit<"point(us)", mag_ratio<1, 12> * pica_us> {} point_us;
|
||||
inline 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_dtp final : named_unit<"point(dtp)", mag_ratio<1, 72> * international::inch> {} point_dtp;
|
||||
constexpr struct pica_dtp final : named_unit<"pica(dtp)", mag<12> * point_dtp> {} pica_dtp;
|
||||
inline 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;
|
||||
// clang-format on
|
||||
|
||||
} // namespace mp_units::typographic
|
||||
|
@ -41,78 +41,78 @@ using namespace international;
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Length
|
||||
// nautical
|
||||
constexpr struct fathom final : named_unit<"ftm(us)", mag<2> * yard> {} fathom;
|
||||
constexpr struct cable final : named_unit<"cb(us)", mag<120> * fathom> {} cable;
|
||||
inline 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;
|
||||
|
||||
// survey
|
||||
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{}> {};
|
||||
|
||||
[[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.")]]
|
||||
constexpr us_survey_foot us_survey_foot;
|
||||
inline 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.")]]
|
||||
constexpr us_survey_mile us_survey_mile;
|
||||
inline constexpr us_survey_mile us_survey_mile;
|
||||
|
||||
constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * foot> {} link;
|
||||
constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
|
||||
constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
|
||||
constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
|
||||
inline 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;
|
||||
inline constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
|
||||
inline constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
|
||||
// clang-format on
|
||||
|
||||
namespace survey1893 {
|
||||
|
||||
// clang-format off
|
||||
constexpr struct us_survey_foot final : named_unit<"ft(us)", mag_ratio<1'200, 3'937> * si::metre> {} us_survey_foot;
|
||||
constexpr struct link final : named_unit<"li", mag_ratio<33, 50> * us_survey_foot> {} link;
|
||||
constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
|
||||
constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
|
||||
constexpr struct furlong final : named_unit<"fur", mag<10> * chain> {} furlong;
|
||||
constexpr struct us_survey_mile final : named_unit<"mi(us)", mag<8> * furlong> {} us_survey_mile;
|
||||
constexpr struct league final : named_unit<"lea", mag<3> * us_survey_mile> {} league;
|
||||
inline 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;
|
||||
inline constexpr struct rod final : named_unit<"rd", mag<25> * link> {} rod;
|
||||
inline constexpr struct chain final : named_unit<"ch", mag<4> * rod> {} chain;
|
||||
inline 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;
|
||||
inline constexpr struct league final : named_unit<"lea", mag<3> * us_survey_mile> {} league;
|
||||
// clang-format on
|
||||
|
||||
} // namespace survey1893
|
||||
|
||||
// clang-format off
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Area
|
||||
constexpr struct acre final : named_unit<"acre", mag<10> * square(survey1893::chain)> {} acre;
|
||||
constexpr struct section final : named_unit<"section", mag<640> * acre> {} section;
|
||||
inline 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;
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Fluid_volume
|
||||
constexpr struct gallon final : named_unit<"gal", mag<231> * cubic(inch)> {} gallon;
|
||||
constexpr struct pottle final : named_unit<"pot", mag_ratio<1, 2> * gallon> {} pottle;
|
||||
constexpr struct quart final : named_unit<"qt", mag_ratio<1, 2> * pottle> {} quart;
|
||||
constexpr struct pint final : named_unit<"pt", mag_ratio<1, 2> * quart> {} pint;
|
||||
constexpr struct cup final : named_unit<"c", mag_ratio<1, 2> * pint> {} cup;
|
||||
constexpr struct gill final : named_unit<"gi", mag_ratio<1, 2> * cup> {} gill;
|
||||
constexpr struct fluid_ounce final : named_unit<"fl oz", mag_ratio<1, 4> * gill> {} fluid_ounce;
|
||||
constexpr struct tablespoon final : named_unit<"tbsp", mag_ratio<1, 2> * fluid_ounce> {} tablespoon;
|
||||
constexpr struct shot final : named_unit<"jig", mag<3> * tablespoon> {} shot;
|
||||
constexpr struct teaspoon final : named_unit<"tsp", mag_ratio<1, 3> * tablespoon> {} teaspoon;
|
||||
constexpr struct minim final : named_unit<"min", mag_ratio<1, 80> * teaspoon> {} minim;
|
||||
constexpr struct fluid_dram final : named_unit<"fl dr", mag<60> * minim> {} fluid_dram;
|
||||
constexpr struct barrel final : named_unit<"bbl", mag_ratio<315, 10> * gallon> {} barrel;
|
||||
constexpr struct oil_barrel final : named_unit<"bbl", mag_ratio<4, 3> * barrel> {} oil_barrel;
|
||||
constexpr struct hogshead final : named_unit<"hogshead", mag<63> * gallon> {} hogshead;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct hogshead final : named_unit<"hogshead", mag<63> * gallon> {} hogshead;
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Dry_volume
|
||||
constexpr struct dry_barrel final : named_unit<"bbl", mag<7056> * cubic(inch)> {} dry_barrel;
|
||||
constexpr struct bushel final : named_unit<"bu", mag_ratio<3'523'907'016'688, 100'000'000'000> * si::litre> {} bushel;
|
||||
constexpr struct peck final : named_unit<"pk", mag_ratio<1, 4> * bushel> {} peck;
|
||||
constexpr struct dry_gallon final : named_unit<"gal", mag_ratio<1, 2> * peck> {} dry_gallon;
|
||||
constexpr struct dry_quart final : named_unit<"qt", mag_ratio<1, 4> * dry_gallon> {} dry_quart;
|
||||
constexpr struct dry_pint final : named_unit<"pt", mag_ratio<1, 2> * dry_quart> {} dry_pint;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline 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;
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Mass_and_Weight
|
||||
// https://en.wikipedia.org/wiki/Avoirdupois_system#American_customary_system
|
||||
constexpr struct quarter final : named_unit<"qr", mag<25> * pound> {} quarter;
|
||||
constexpr struct short_hundredweight final : named_unit<"cwt", mag<100> * pound> {} short_hundredweight;
|
||||
constexpr struct ton final : named_unit<"t", mag<2'000> * pound> {} ton;
|
||||
constexpr auto short_ton = ton;
|
||||
constexpr struct pennyweight final : named_unit<"dwt", mag<24> * grain> {} pennyweight;
|
||||
constexpr struct troy_once final : named_unit<"oz t", mag<20> * pennyweight> {} troy_once;
|
||||
constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_once> {} troy_pound;
|
||||
inline 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;
|
||||
inline constexpr struct ton final : named_unit<"t", mag<2'000> * pound> {} ton;
|
||||
inline constexpr auto short_ton = ton;
|
||||
inline 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;
|
||||
inline constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_once> {} troy_pound;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Inch_of_mercury
|
||||
#ifdef pascal
|
||||
@ -120,15 +120,15 @@ constexpr struct troy_pound final : named_unit<"lb t", mag<12> * troy_once> {} t
|
||||
#undef pascal
|
||||
#define MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
constexpr struct inch_of_mercury final : named_unit<"inHg", mag_ratio<3'386'389, 1'000> * si::pascal> {} inch_of_mercury;
|
||||
inline 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
|
||||
#pragma pop_macro("pascal")
|
||||
#undef MP_UNITS_REDEFINE_PASCAL
|
||||
#endif
|
||||
|
||||
// https://en.wikipedia.org/wiki/United_States_customary_units#Temperature
|
||||
constexpr struct zeroth_degree_Fahrenheit final : relative_point_origin<absolute<mag_ratio<5, 9> * si::degree_Celsius>(-32)> {} zeroth_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;
|
||||
inline 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;
|
||||
|
||||
// clang-format on
|
||||
|
||||
@ -136,51 +136,51 @@ namespace unit_symbols {
|
||||
|
||||
using namespace international::unit_symbols;
|
||||
|
||||
constexpr auto ftm = fathom;
|
||||
constexpr auto cb = cable;
|
||||
inline constexpr auto ftm = fathom;
|
||||
inline constexpr auto cb = cable;
|
||||
[[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.")]] constexpr struct us_survey_foot us_ft;
|
||||
"deprecated.")]] inline constexpr struct us_survey_foot us_ft;
|
||||
[[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.")]] constexpr struct us_survey_mile us_mi;
|
||||
constexpr auto li = link;
|
||||
constexpr auto rd = rod;
|
||||
constexpr auto ch = chain;
|
||||
constexpr auto fur = furlong;
|
||||
constexpr auto lea = league;
|
||||
"deprecated.")]] inline constexpr struct us_survey_mile us_mi;
|
||||
inline constexpr auto li = link;
|
||||
inline constexpr auto rd = rod;
|
||||
inline constexpr auto ch = chain;
|
||||
inline constexpr auto fur = furlong;
|
||||
inline constexpr auto lea = league;
|
||||
|
||||
constexpr auto gal = gallon;
|
||||
constexpr auto pot = pottle;
|
||||
constexpr auto qt = quart;
|
||||
constexpr auto pt = pint;
|
||||
constexpr auto c = cup;
|
||||
constexpr auto gi = gill;
|
||||
constexpr auto fl_oz = fluid_ounce;
|
||||
constexpr auto tbsp = tablespoon;
|
||||
constexpr auto jig = shot;
|
||||
constexpr auto tsp = teaspoon;
|
||||
constexpr auto min = minim;
|
||||
constexpr auto fl_dr = fluid_dram;
|
||||
constexpr auto bbl = barrel;
|
||||
inline constexpr auto gal = gallon;
|
||||
inline constexpr auto pot = pottle;
|
||||
inline constexpr auto qt = quart;
|
||||
inline constexpr auto pt = pint;
|
||||
inline constexpr auto c = cup;
|
||||
inline constexpr auto gi = gill;
|
||||
inline constexpr auto fl_oz = fluid_ounce;
|
||||
inline constexpr auto tbsp = tablespoon;
|
||||
inline constexpr auto jig = shot;
|
||||
inline constexpr auto tsp = teaspoon;
|
||||
inline constexpr auto min = minim;
|
||||
inline constexpr auto fl_dr = fluid_dram;
|
||||
inline constexpr auto bbl = barrel;
|
||||
|
||||
constexpr auto dry_bbl = dry_barrel;
|
||||
constexpr auto bu = bushel;
|
||||
constexpr auto pk = peck;
|
||||
constexpr auto dry_gal = dry_gallon;
|
||||
constexpr auto dry_qt = dry_quart;
|
||||
constexpr auto dry_pt = dry_pint;
|
||||
inline constexpr auto dry_bbl = dry_barrel;
|
||||
inline constexpr auto bu = bushel;
|
||||
inline constexpr auto pk = peck;
|
||||
inline constexpr auto dry_gal = dry_gallon;
|
||||
inline constexpr auto dry_qt = dry_quart;
|
||||
inline constexpr auto dry_pt = dry_pint;
|
||||
|
||||
constexpr auto qr = quarter;
|
||||
constexpr auto cwt = short_hundredweight;
|
||||
constexpr auto t = ton;
|
||||
constexpr auto dwt = pennyweight;
|
||||
constexpr auto oz_t = troy_once;
|
||||
constexpr auto lb_t = troy_pound;
|
||||
inline constexpr auto qr = quarter;
|
||||
inline constexpr auto cwt = short_hundredweight;
|
||||
inline constexpr auto t = ton;
|
||||
inline constexpr auto dwt = pennyweight;
|
||||
inline constexpr auto oz_t = troy_once;
|
||||
inline constexpr auto lb_t = troy_pound;
|
||||
|
||||
constexpr auto inHg = inch_of_mercury;
|
||||
inline constexpr auto inHg = inch_of_mercury;
|
||||
|
||||
constexpr auto deg_F = degree_Fahrenheit;
|
||||
inline constexpr auto deg_F = degree_Fahrenheit;
|
||||
|
||||
} // namespace unit_symbols
|
||||
|
||||
|
@ -42,9 +42,9 @@ using namespace mp_units;
|
||||
using namespace mp_units::angular;
|
||||
using namespace mp_units::angular::unit_symbols;
|
||||
|
||||
constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> {
|
||||
inline constexpr struct half_revolution final : named_unit<"hrev", mag_pi * radian> {
|
||||
} half_revolution;
|
||||
constexpr auto hrev = half_revolution;
|
||||
inline constexpr auto hrev = half_revolution;
|
||||
|
||||
// constexpr auto revb6 = mag_ratio<1,3> * mag_pi * rad;
|
||||
|
||||
|
@ -44,12 +44,12 @@ namespace {
|
||||
|
||||
using namespace mp_units;
|
||||
|
||||
constexpr struct my_origin final : absolute_point_origin<isq::length> {
|
||||
inline constexpr struct my_origin final : absolute_point_origin<isq::length> {
|
||||
} my_origin;
|
||||
constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> {
|
||||
inline constexpr struct my_relative_origin final : relative_point_origin<my_origin + isq::length(42 * si::metre)> {
|
||||
} my_relative_origin;
|
||||
|
||||
constexpr auto dim_speed = isq::dim_length / isq::dim_time;
|
||||
inline constexpr auto dim_speed = isq::dim_length / isq::dim_time;
|
||||
|
||||
// BaseDimension
|
||||
static_assert(detail::BaseDimension<struct isq::dim_length>);
|
||||
@ -78,7 +78,7 @@ static_assert(!Dimension<int>);
|
||||
// TODO add tests
|
||||
|
||||
// QuantitySpec
|
||||
constexpr auto speed = isq::length / isq::time;
|
||||
inline constexpr auto speed = isq::length / isq::time;
|
||||
|
||||
static_assert(QuantitySpec<struct isq::length>);
|
||||
static_assert(QuantitySpec<struct isq::radius>);
|
||||
|
@ -36,31 +36,31 @@ using namespace mp_units;
|
||||
using dimension_one_ = struct dimension_one;
|
||||
|
||||
// clang-format off
|
||||
constexpr struct length_ final : base_dimension<"L"> {} length;
|
||||
constexpr struct mass_ final : base_dimension<"M"> {} mass;
|
||||
constexpr struct time_ final : base_dimension<"T"> {} time;
|
||||
inline constexpr struct length_ final : base_dimension<"L"> {} length;
|
||||
inline constexpr struct mass_ final : base_dimension<"M"> {} mass;
|
||||
inline constexpr struct time_ final : base_dimension<"T"> {} time;
|
||||
|
||||
constexpr auto my_length1 = length;
|
||||
constexpr auto my_length2 = length;
|
||||
inline constexpr auto my_length1 = length;
|
||||
inline constexpr auto my_length2 = length;
|
||||
|
||||
QUANTITY_SPEC_(q_time, time);
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second;
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<q_time>> {} second;
|
||||
|
||||
constexpr auto frequency = inverse(time);
|
||||
constexpr auto action = inverse(time);
|
||||
constexpr auto area = length * length;
|
||||
constexpr auto volume = area * length;
|
||||
constexpr auto speed = length / time;
|
||||
constexpr auto acceleration = speed / time;
|
||||
constexpr auto force = mass * acceleration;
|
||||
constexpr auto moment_of_force = length * force;
|
||||
constexpr auto torque = moment_of_force;
|
||||
constexpr auto pressure = force / area;
|
||||
constexpr auto stress = pressure;
|
||||
constexpr auto strain = stress / stress;
|
||||
constexpr auto power = force * speed;
|
||||
constexpr auto efficiency = power / power;
|
||||
constexpr auto energy = force * length;
|
||||
inline constexpr auto frequency = inverse(time);
|
||||
inline constexpr auto action = inverse(time);
|
||||
inline constexpr auto area = length * length;
|
||||
inline constexpr auto volume = area * length;
|
||||
inline constexpr auto speed = length / time;
|
||||
inline constexpr auto acceleration = speed / time;
|
||||
inline constexpr auto force = mass * acceleration;
|
||||
inline constexpr auto moment_of_force = length * force;
|
||||
inline constexpr auto torque = moment_of_force;
|
||||
inline constexpr auto pressure = force / area;
|
||||
inline constexpr auto stress = pressure;
|
||||
inline constexpr auto strain = stress / stress;
|
||||
inline constexpr auto power = force * speed;
|
||||
inline constexpr auto efficiency = power / power;
|
||||
inline constexpr auto energy = force * length;
|
||||
// clang-format on
|
||||
|
||||
// concepts verification
|
||||
|
@ -71,11 +71,11 @@ namespace {
|
||||
// CHECK(round_trip == R);
|
||||
// }
|
||||
|
||||
constexpr struct mag_2_ : magnitude<2> {
|
||||
inline constexpr struct mag_2_ : magnitude<2> {
|
||||
} mag_2;
|
||||
// constexpr struct mag_2_other : magnitude<2> {
|
||||
// inline constexpr struct mag_2_other : magnitude<2> {
|
||||
// } mag_2_other;
|
||||
// constexpr struct mag_3 : magnitude<2> {
|
||||
// inline constexpr struct mag_3 : magnitude<2> {
|
||||
// } mag_3;
|
||||
|
||||
// concepts verification
|
||||
|
@ -50,38 +50,38 @@ using namespace std::chrono_literals;
|
||||
using sys_seconds = std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>;
|
||||
#endif
|
||||
|
||||
constexpr struct zeroth_length final : absolute_point_origin<isq::length> {
|
||||
inline constexpr struct zeroth_length final : absolute_point_origin<isq::length> {
|
||||
} zeroth_length;
|
||||
|
||||
constexpr struct mean_sea_level final : absolute_point_origin<isq::height> {
|
||||
inline constexpr struct mean_sea_level final : absolute_point_origin<isq::height> {
|
||||
} mean_sea_level;
|
||||
|
||||
constexpr auto my_mean_sea_level = mean_sea_level;
|
||||
inline constexpr auto my_mean_sea_level = mean_sea_level;
|
||||
|
||||
constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> {
|
||||
inline constexpr struct same_mean_sea_level final : relative_point_origin<mean_sea_level + 0 * isq::height[m]> {
|
||||
} same_mean_sea_level;
|
||||
|
||||
constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
inline constexpr struct ground_level final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
} ground_level;
|
||||
|
||||
constexpr auto my_ground_level = ground_level;
|
||||
inline constexpr auto my_ground_level = ground_level;
|
||||
|
||||
constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
inline constexpr struct same_ground_level1 final : relative_point_origin<mean_sea_level + 42 * isq::height[m]> {
|
||||
} same_ground_level1;
|
||||
|
||||
constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> {
|
||||
inline constexpr struct same_ground_level2 final : relative_point_origin<my_mean_sea_level + 42 * isq::height[m]> {
|
||||
} same_ground_level2;
|
||||
|
||||
constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> {
|
||||
inline constexpr struct tower_peak final : relative_point_origin<ground_level + 42 * isq::height[m]> {
|
||||
} tower_peak;
|
||||
|
||||
constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> {
|
||||
inline constexpr struct other_ground_level final : relative_point_origin<mean_sea_level + 123 * isq::height[m]> {
|
||||
} other_ground_level;
|
||||
|
||||
constexpr struct other_absolute_level final : absolute_point_origin<isq::height> {
|
||||
inline constexpr struct other_absolute_level final : absolute_point_origin<isq::height> {
|
||||
} other_absolute_level;
|
||||
|
||||
constexpr struct zero final : absolute_point_origin<dimensionless> {
|
||||
inline constexpr struct zero final : absolute_point_origin<dimensionless> {
|
||||
} zero;
|
||||
|
||||
QUANTITY_SPEC(special_height, isq::height);
|
||||
@ -122,7 +122,7 @@ static_assert(relative_po<absolute_po<isq::length> + isq::height(42 * m)>.quanti
|
||||
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);
|
||||
|
||||
constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> {
|
||||
inline constexpr struct my_kelvin final : named_unit<"my_K", mag<10> * si::kelvin> {
|
||||
} my_kelvin;
|
||||
|
||||
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(tower_peak - other_ground_level == -39 * m);
|
||||
|
||||
constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> {
|
||||
inline constexpr struct zero_m_per_s final : absolute_point_origin<kind_of<isq::speed>> {
|
||||
} zero_m_per_s;
|
||||
|
||||
// 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])),
|
||||
quantity_point<(isq::height / isq::time)[m / s], zeroth_point_origin<isq::height / isq::time>, int>>);
|
||||
|
||||
constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> {
|
||||
inline constexpr struct zero_Hz final : absolute_point_origin<kind_of<isq::frequency>> {
|
||||
} 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); };
|
||||
}
|
||||
|
||||
constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> {
|
||||
inline constexpr struct zero_Bq final : absolute_point_origin<kind_of<isq::activity>> {
|
||||
} zero_Bq;
|
||||
|
||||
static_assert(invalid_addition(zero_Bq + 5 * isq::activity[Bq], 5 * isq::frequency[Hz]));
|
||||
|
@ -37,22 +37,22 @@ using dimensionless_ = struct dimensionless;
|
||||
using dim_one_ = struct dimension_one;
|
||||
|
||||
// clang-format off
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
QUANTITY_SPEC_(mass, dim_mass);
|
||||
QUANTITY_SPEC_(time, dim_time);
|
||||
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
|
||||
QUANTITY_SPEC_(height, length);
|
||||
QUANTITY_SPEC_(width, length);
|
||||
QUANTITY_SPEC_(radius, width);
|
||||
QUANTITY_SPEC_(path_length, length);
|
||||
constexpr auto arc_length = path_length;
|
||||
inline constexpr auto arc_length = path_length;
|
||||
QUANTITY_SPEC_(distance, path_length);
|
||||
QUANTITY_SPEC_(position_vector, length, quantity_character::vector);
|
||||
QUANTITY_SPEC_(period_duration, time);
|
||||
|
@ -39,9 +39,9 @@ using one_ = struct one;
|
||||
|
||||
// base dimensions
|
||||
// clang-format off
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
@ -64,37 +64,37 @@ QUANTITY_SPEC_(power, force* speed);
|
||||
QUANTITY_SPEC_(storage_capacity, dimensionless, is_kind);
|
||||
|
||||
// base units
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
constexpr auto kilogram = si::kilo<gram>;
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
inline constexpr auto kilogram = si::kilo<gram>;
|
||||
|
||||
namespace nu {
|
||||
// hypothetical natural system of units for c=1
|
||||
|
||||
constexpr struct second_ final : named_unit<"s"> {} second;
|
||||
constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline constexpr struct second_ final : named_unit<"s"> {} second;
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
|
||||
constexpr struct time : system_reference<time_{}, second> {} time;
|
||||
constexpr struct length : system_reference<length_{}, second> {} length;
|
||||
constexpr struct speed : system_reference<speed_{}, second / second> {} speed;
|
||||
inline constexpr struct time : system_reference<time_{}, second> {} time;
|
||||
inline constexpr struct length : system_reference<length_{}, second> {} length;
|
||||
inline constexpr struct speed : system_reference<speed_{}, second / second> {} speed;
|
||||
|
||||
}
|
||||
|
||||
// derived named units
|
||||
constexpr struct radian_ final : named_unit<"rad", metre / metre, kind_of<angular_measure>> {} radian;
|
||||
constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre), kind_of<solid_angular_measure>> {} steradian;
|
||||
constexpr struct hertz_ final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
|
||||
constexpr struct becquerel_ final : named_unit<"Bq", inverse(second), kind_of<activity>> {} becquerel;
|
||||
constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
inline 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;
|
||||
inline 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;
|
||||
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
|
||||
constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr auto kilometre = si::kilo<metre>;
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
inline constexpr auto kilometre = si::kilo<metre>;
|
||||
|
||||
constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
inline constexpr struct bit_ final : named_unit<"bit", one, kind_of<storage_capacity>> {} bit;
|
||||
// clang-format on
|
||||
|
||||
|
||||
|
@ -36,14 +36,14 @@ constexpr bool is_of_type = std::is_same_v<MP_UNITS_REMOVE_CONST(decltype(V)), T
|
||||
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
|
||||
#if MP_UNITS_API_NO_CRTP
|
||||
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
inline constexpr struct name##_ final : quantity_spec<__VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#else
|
||||
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \
|
||||
#define QUANTITY_SPEC_(name, ...) \
|
||||
inline constexpr struct name##_ final : quantity_spec<name##_, __VA_ARGS__> { \
|
||||
} name
|
||||
|
||||
#endif
|
||||
|
@ -40,10 +40,10 @@ using percent_ = struct percent;
|
||||
|
||||
// base dimensions
|
||||
// clang-format off
|
||||
constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
constexpr struct dim_time_ final : base_dimension<"T"> {} dim_time;
|
||||
constexpr struct dim_thermodynamic_temperature_ final : base_dimension<symbol_text{u8"Θ", "O"}> {} dim_thermodynamic_temperature;
|
||||
inline constexpr struct dim_length_ final : base_dimension<"L"> {} dim_length;
|
||||
inline constexpr struct dim_mass_ final : base_dimension<"M"> {} dim_mass;
|
||||
inline 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;
|
||||
|
||||
// quantities specification
|
||||
QUANTITY_SPEC_(length, dim_length);
|
||||
@ -52,39 +52,39 @@ QUANTITY_SPEC_(time, dim_time);
|
||||
QUANTITY_SPEC_(thermodynamic_temperature, dim_thermodynamic_temperature);
|
||||
|
||||
// base units
|
||||
constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
constexpr auto kilogram = si::kilo<gram>;
|
||||
constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin;
|
||||
inline constexpr struct second_ final : named_unit<"s", kind_of<time>> {} second;
|
||||
inline constexpr struct metre_ final : named_unit<"m", kind_of<length>> {} metre;
|
||||
inline constexpr struct gram_ final : named_unit<"g", kind_of<mass>> {} gram;
|
||||
inline constexpr auto kilogram = si::kilo<gram>;
|
||||
inline constexpr struct kelvin_ final : named_unit<"K", kind_of<thermodynamic_temperature>> {} kelvin;
|
||||
|
||||
// hypothetical natural units for c=1
|
||||
constexpr struct nu_second_ final : named_unit<"s"> {} nu_second;
|
||||
inline constexpr struct nu_second_ final : named_unit<"s"> {} nu_second;
|
||||
|
||||
// derived named units
|
||||
constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian;
|
||||
constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian;
|
||||
constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz;
|
||||
constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel;
|
||||
constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
|
||||
constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"℃", "`C"}, kelvin> {} degree_Celsius;
|
||||
inline constexpr struct radian_ final : named_unit<"rad", metre / metre> {} radian;
|
||||
inline constexpr struct steradian_ final : named_unit<"sr", square(metre) / square(metre)> {} steradian;
|
||||
inline constexpr struct hertz_ final : named_unit<"Hz", inverse(second)> {} hertz;
|
||||
inline constexpr struct becquerel_ final : named_unit<"Bq", inverse(second)> {} becquerel;
|
||||
inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / square(second)> {} newton;
|
||||
inline constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
|
||||
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
|
||||
inline 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 minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;
|
||||
constexpr struct degree_ final : named_unit<symbol_text{u8"°", "deg"}, mag_pi / mag<180> * radian> {} degree;
|
||||
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
|
||||
inline 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 yard_ final : named_unit<"yd", mag_ratio<9'144, 10'000> * metre> {} yard;
|
||||
constexpr struct mile_ final : named_unit<"mi", mag<1760> * yard> {} mile;
|
||||
inline 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 auto kilometre = si::kilo<metre>;
|
||||
constexpr auto kilojoule = si::kilo<joule>;
|
||||
inline constexpr auto kilometre = si::kilo<metre>;
|
||||
inline constexpr auto kilojoule = si::kilo<joule>;
|
||||
|
||||
// physical constant units
|
||||
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 speed_of_light_in_vacuum_ final : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum;
|
||||
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;
|
||||
inline 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
|
||||
|
||||
|
Reference in New Issue
Block a user