mirror of
https://github.com/mpusz/mp-units.git
synced 2026-07-09 10:00:55 +02:00
docs: non_negative declarations added to quantity_spec in docs
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -63,7 +63,7 @@ This is how we can model it in C++:
|
||||
```cpp
|
||||
inline constexpr struct dim_length final : base_dimension<"L"> {} dim_length;
|
||||
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct length final : quantity_spec<dim_length, non_negative> {} length;
|
||||
inline constexpr struct width final : quantity_spec<length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
inline constexpr struct height final : quantity_spec<length> {} height;
|
||||
|
||||
@@ -74,8 +74,8 @@ provided in the [quantity specification](../../reference/glossary.md#quantity_sp
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct time final : quantity_spec<dim_time> {} time;
|
||||
inline constexpr struct length final : quantity_spec<dim_length, non_negative> {} length;
|
||||
inline constexpr struct time final : quantity_spec<dim_time, non_negative> {} time;
|
||||
inline constexpr struct speed final : quantity_spec<length / time> {} speed;
|
||||
|
||||
static_assert(speed.dimension == dim_length / dim_time);
|
||||
@@ -84,8 +84,8 @@ provided in the [quantity specification](../../reference/glossary.md#quantity_sp
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
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 length final : quantity_spec<length, dim_length, non_negative> {} length;
|
||||
inline constexpr struct time final : quantity_spec<time, dim_time, non_negative> {} time;
|
||||
inline constexpr struct speed final : quantity_spec<speed, length / time> {} speed;
|
||||
|
||||
static_assert(speed.dimension == dim_length / dim_time);
|
||||
@@ -94,8 +94,8 @@ provided in the [quantity specification](../../reference/glossary.md#quantity_sp
|
||||
=== "Portable"
|
||||
|
||||
```cpp
|
||||
QUANTITY_SPEC(length, dim_length);
|
||||
QUANTITY_SPEC(time, dim_time);
|
||||
QUANTITY_SPEC(length, dim_length, non_negative);
|
||||
QUANTITY_SPEC(time, dim_time, non_negative);
|
||||
QUANTITY_SPEC(speed, length / time);
|
||||
|
||||
static_assert(speed.dimension == dim_length / dim_time);
|
||||
|
||||
@@ -156,7 +156,7 @@ For example, here is how the above quantity kind tree can be modeled in the libr
|
||||
=== "C++23"
|
||||
|
||||
```cpp
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct length final : quantity_spec<dim_length, non_negative> {} length;
|
||||
inline constexpr struct width final : quantity_spec<length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
// V2 workaround: altitude/depth as children of length, height as child of altitude
|
||||
@@ -179,7 +179,7 @@ For example, here is how the above quantity kind tree can be modeled in the libr
|
||||
=== "C++20"
|
||||
|
||||
```cpp
|
||||
inline constexpr struct length final : quantity_spec<length, dim_length> {} length;
|
||||
inline constexpr struct length final : quantity_spec<length, dim_length, non_negative> {} length;
|
||||
inline constexpr struct width final : quantity_spec<width, length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
// V2 workaround: altitude/depth as children of length, height as child of altitude
|
||||
@@ -202,7 +202,7 @@ For example, here is how the above quantity kind tree can be modeled in the libr
|
||||
=== "Portable"
|
||||
|
||||
```cpp
|
||||
QUANTITY_SPEC(length, dim_length);
|
||||
QUANTITY_SPEC(length, dim_length, non_negative);
|
||||
QUANTITY_SPEC(width, length);
|
||||
inline constexpr auto breadth = width;
|
||||
// V2 workaround: altitude/depth as children of length, height as child of altitude
|
||||
|
||||
@@ -65,13 +65,13 @@ For each base dimension, the ISQ defines corresponding base quantities:
|
||||
```cpp
|
||||
namespace mp_units::isq {
|
||||
|
||||
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;
|
||||
inline constexpr struct length final : quantity_spec<dim_length, non_negative> {} length;
|
||||
inline constexpr struct mass final : quantity_spec<dim_mass, non_negative> {} mass;
|
||||
inline constexpr struct time final : quantity_spec<dim_time, non_negative> {} time;
|
||||
inline constexpr struct electric_current final : quantity_spec<dim_electric_current> {} electric_current;
|
||||
inline constexpr struct thermodynamic_temperature final : quantity_spec<dim_thermodynamic_temperature> {} thermodynamic_temperature;
|
||||
inline constexpr struct amount_of_substance final : quantity_spec<dim_amount_of_substance> {} amount_of_substance;
|
||||
inline constexpr struct luminous_intensity final : quantity_spec<dim_luminous_intensity> {} luminous_intensity;
|
||||
inline constexpr struct thermodynamic_temperature final : quantity_spec<dim_thermodynamic_temperature, non_negative> {} thermodynamic_temperature;
|
||||
inline constexpr struct amount_of_substance final : quantity_spec<dim_amount_of_substance, non_negative> {} amount_of_substance;
|
||||
inline constexpr struct luminous_intensity final : quantity_spec<dim_luminous_intensity, non_negative> {} luminous_intensity;
|
||||
|
||||
}
|
||||
```
|
||||
@@ -151,7 +151,7 @@ flowchart TD
|
||||
In code:
|
||||
|
||||
```cpp
|
||||
inline constexpr struct length final : quantity_spec<dim_length> {} length;
|
||||
inline constexpr struct length final : quantity_spec<dim_length, non_negative> {} length;
|
||||
inline constexpr struct width final : quantity_spec<length> {} width;
|
||||
inline constexpr auto breadth = width;
|
||||
inline constexpr struct height final : quantity_spec<length> {} height;
|
||||
|
||||
Reference in New Issue
Block a user