From c60f94caa3e04f0bbe8b0c11407e083547507ab3 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 10 Jul 2023 12:33:54 +0200 Subject: [PATCH] docs: code samples with `quantity_spec` definitions now have 3 versions --- .../framework_basics/basic_concepts.md | 28 +++++-- .../character_of_a_quantity.md | 44 ++++++++-- .../framework_basics/systems_of_quantities.md | 84 ++++++++++++++----- 3 files changed, 125 insertions(+), 31 deletions(-) diff --git a/docs/users_guide/framework_basics/basic_concepts.md b/docs/users_guide/framework_basics/basic_concepts.md index 425278a0..ce49605d 100644 --- a/docs/users_guide/framework_basics/basic_concepts.md +++ b/docs/users_guide/framework_basics/basic_concepts.md @@ -95,11 +95,29 @@ including: `QuantitySpec` can be defined by the user in one of the following ways: - ```cpp - inline constexpr struct length : quantity_spec {} length; - inline constexpr struct height : quantity_spec {} height; - inline constexpr struct speed : quantity_spec {} speed; - ``` + === "C++20" + + ```cpp + inline constexpr struct length : quantity_spec {} length; + inline constexpr struct height : quantity_spec {} height; + inline constexpr struct speed : quantity_spec {} speed; + ``` + + === "C++23" + + ```cpp + inline constexpr struct length : quantity_spec {} length; + inline constexpr struct height : quantity_spec {} height; + inline constexpr struct speed : quantity_spec {} speed; + ``` + + === "Portable" + + ```cpp + QUANTITY_SPEC(length, dim_length); + QUANTITY_SPEC(height, length); + QUANTITY_SPEC(speed, length / time); + ``` ## `Unit` diff --git a/docs/users_guide/framework_basics/character_of_a_quantity.md b/docs/users_guide/framework_basics/character_of_a_quantity.md index 5ef80aae..e7d8ca02 100644 --- a/docs/users_guide/framework_basics/character_of_a_quantity.md +++ b/docs/users_guide/framework_basics/character_of_a_quantity.md @@ -94,10 +94,26 @@ Also, it explicitly states that: To specify that a specific quantity has a vector or tensor character a value of `quantity_character` enumeration can be appended to the `quantity_spec` describing such a quantity type: -```cpp -inline constexpr struct position_vector : quantity_spec {} position_vector; -inline constexpr struct displacement : quantity_spec {} displacement; -``` +=== "C++20" + + ```cpp + inline constexpr struct position_vector : quantity_spec {} position_vector; + inline constexpr struct displacement : quantity_spec {} displacement; + ``` + +=== "C++23" + + ```cpp + inline constexpr struct position_vector : quantity_spec {} position_vector; + inline constexpr struct displacement : quantity_spec {} displacement; + ``` + +=== "Portable" + + ```cpp + QUANTITY_SPEC(position_vector, length, quantity_character::vector); + QUANTITY_SPEC(displacement, length, quantity_character::vector); + ``` With the above, all the quantities derived from `position_vector` or `displacement` will have a correct character determined according to the kind of operations included in the @@ -107,9 +123,23 @@ character determined according to the kind of operations included in the For example, `velocity` in the below definition will be defined as a vector quantity (no explicit character override is needed): -```cpp -inline constexpr struct velocity : quantity_spec {} velocity; -``` +=== "C++20" + + ```cpp + inline constexpr struct velocity : quantity_spec {} velocity; + ``` + +=== "C++23" + + ```cpp + inline constexpr struct velocity : quantity_spec {} velocity; + ``` + +=== "Portable" + + ```cpp + QUANTITY_SPEC(velocity, speed, position_vector / duration); + ``` ## Representation types for vector and tensor quantities diff --git a/docs/users_guide/framework_basics/systems_of_quantities.md b/docs/users_guide/framework_basics/systems_of_quantities.md index 52fd367a..663557ae 100644 --- a/docs/users_guide/framework_basics/systems_of_quantities.md +++ b/docs/users_guide/framework_basics/systems_of_quantities.md @@ -121,25 +121,71 @@ from such an instantiation. For example, here is how the above quantity kind tree can be modeled in the library: -```cpp -inline constexpr struct length : quantity_spec {} length; -inline constexpr struct width : quantity_spec {} width; -inline constexpr auto breadth = width; -inline constexpr struct height : quantity_spec {} height; -inline constexpr auto depth = height; -inline constexpr auto altitude = height; -inline constexpr struct thickness : quantity_spec {} thickness; -inline constexpr struct diameter : quantity_spec {} diameter; -inline constexpr struct radius : quantity_spec {} radius; -inline constexpr struct radius_of_curvature : quantity_spec {} radius_of_curvature; -inline constexpr struct path_length : quantity_spec {} path_length; -inline constexpr auto arc_length = path_length; -inline constexpr struct distance : quantity_spec {} distance; -inline constexpr struct radial_distance : quantity_spec {} radial_distance; -inline constexpr struct wavelength : quantity_spec {} wavelength; -inline constexpr struct position_vector : quantity_spec {} position_vector; -inline constexpr struct displacement : quantity_spec {} displacement; -``` +=== "C++20" + + ```cpp + inline constexpr struct length : quantity_spec {} length; + inline constexpr struct width : quantity_spec {} width; + inline constexpr auto breadth = width; + inline constexpr struct height : quantity_spec {} height; + inline constexpr auto depth = height; + inline constexpr auto altitude = height; + inline constexpr struct thickness : quantity_spec {} thickness; + inline constexpr struct diameter : quantity_spec {} diameter; + inline constexpr struct radius : quantity_spec {} radius; + inline constexpr struct radius_of_curvature : quantity_spec {} radius_of_curvature; + inline constexpr struct path_length : quantity_spec {} path_length; + inline constexpr auto arc_length = path_length; + inline constexpr struct distance : quantity_spec {} distance; + inline constexpr struct radial_distance : quantity_spec {} radial_distance; + inline constexpr struct wavelength : quantity_spec {} wavelength; + inline constexpr struct position_vector : quantity_spec {} position_vector; + inline constexpr struct displacement : quantity_spec {} displacement; + ``` + +=== "C++23" + + ```cpp + inline constexpr struct length : quantity_spec {} length; + inline constexpr struct width : quantity_spec {} width; + inline constexpr auto breadth = width; + inline constexpr struct height : quantity_spec {} height; + inline constexpr auto depth = height; + inline constexpr auto altitude = height; + inline constexpr struct thickness : quantity_spec {} thickness; + inline constexpr struct diameter : quantity_spec {} diameter; + inline constexpr struct radius : quantity_spec {} radius; + inline constexpr struct radius_of_curvature : quantity_spec {} radius_of_curvature; + inline constexpr struct path_length : quantity_spec {} path_length; + inline constexpr auto arc_length = path_length; + inline constexpr struct distance : quantity_spec {} distance; + inline constexpr struct radial_distance : quantity_spec {} radial_distance; + inline constexpr struct wavelength : quantity_spec {} wavelength; + inline constexpr struct position_vector : quantity_spec {} position_vector; + inline constexpr struct displacement : quantity_spec {} displacement; + ``` + +=== "Portable" + + ```cpp + QUANTITY_SPEC(length, dim_length); + QUANTITY_SPEC(width, length); + inline constexpr auto breadth = width; + QUANTITY_SPEC(height, length); + 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); + inline constexpr auto arc_length = path_length; + QUANTITY_SPEC(distance, path_length); + QUANTITY_SPEC(radial_distance, distance); + QUANTITY_SPEC(wavelength, length); + QUANTITY_SPEC(position_vector, length, quantity_character::vector); + QUANTITY_SPEC(displacement, length, quantity_character::vector); + ``` !!! note