diff --git a/docs/appendix/glossary.md b/docs/appendix/glossary.md index 3670cd73..1e61429c 100644 --- a/docs/appendix/glossary.md +++ b/docs/appendix/glossary.md @@ -270,7 +270,7 @@ [`derived dimension`](#derived-dimension){ #derived-dimension } : - A [dimension](#dimension) of a [derived quantity](#derived-quantity). - - Implemented as an expression template being the result of the + - Implemented as an symbolic expression being the result of the [dimension equation](#dimension-equation) on [base dimensions](#base-dimension). [`dimension equation`](#dimension-equation){ #dimension-equation } diff --git a/docs/getting_started/faq.md b/docs/getting_started/faq.md index 37d4edd9..e94ddb75 100644 --- a/docs/getting_started/faq.md +++ b/docs/getting_started/faq.md @@ -159,7 +159,7 @@ The above prints: Some users could expect to see `42 kWh` or `42 kW h` in the output. It is not the case and for a very good reason. As stated in -[Simplifying the resulting expression templates](../users_guide/framework_basics/interface_introduction.md#simplifying-the-resulting-expression-templates), +[Simplifying the resulting symbolic expressions](../users_guide/framework_basics/interface_introduction.md#simplifying-the-resulting-symbolic-expressions), to be able to reason about and simplify units, the library needs to order them in an appropriate order. diff --git a/docs/getting_started/introduction.md b/docs/getting_started/introduction.md index b15b54e0..4c8eff53 100644 --- a/docs/getting_started/introduction.md +++ b/docs/getting_started/introduction.md @@ -35,7 +35,7 @@ To achieve this goal, several techniques are applied: compile-times and the readability of error messages when compared to the traditional template metaprogramming with [SFINAE](https://en.cppreference.com/w/cpp/language/sfinae), - [usage of strong types for framework entities](../users_guide/framework_basics/interface_introduction.md#strong-types-instead-of-aliases) (instead of type aliases), -- [usage of expression templates](../users_guide/framework_basics/interface_introduction.md#expression-templates) to improve the readability of generated types, +- [usage of symbolic expressions](../users_guide/framework_basics/interface_introduction.md#symbolic-expressions) to improve the readability of generated types, - limiting the number of template arguments to the bare minimum. !!! important "Important: It is all about errors" diff --git a/docs/users_guide/framework_basics/dimensionless_quantities.md b/docs/users_guide/framework_basics/dimensionless_quantities.md index 0ef90213..b7a9555e 100644 --- a/docs/users_guide/framework_basics/dimensionless_quantities.md +++ b/docs/users_guide/framework_basics/dimensionless_quantities.md @@ -141,7 +141,7 @@ ratio of `1` and does not output any textual symbol. !!! important "Important: `one` is an identity" A unit `one` is special in the entire type system of units as it is considered to be - [an identity operand in the unit expression templates](interface_introduction.md#identities). + [an identity operand in the unit symbolic expressions](interface_introduction.md#identities). This means that, for example: ```cpp diff --git a/docs/users_guide/framework_basics/interface_introduction.md b/docs/users_guide/framework_basics/interface_introduction.md index 31ebef0a..49c152db 100644 --- a/docs/users_guide/framework_basics/interface_introduction.md +++ b/docs/users_guide/framework_basics/interface_introduction.md @@ -24,7 +24,7 @@ behind this is that: Also, to prevent possible issues in compile-time logic, all of the library's entities must be marked `final`. This prevents the users to derive own strong types from them, which would - prevent expression template simplification of equivalent entities. + prevent symbolic expressions simplification of equivalent entities. ## Strong types instead of aliases @@ -103,14 +103,14 @@ inline constexpr struct joule final : named_unit<"J", newton * metre> {} joule; ``` -## Expression templates +## Symbolic expressions The previous chapter provided a rationale for not having predefined types for derived entities. In many libraries, such an approach results in long and unreadable compilation errors, as framework-generated types are typically far from being easy to read and understand. The **mp-units** library greatly improves the user experience by extensively using -expression templates. Such expressions are used consistently throughout the entire library +symbolic expressions. Such expressions are used consistently throughout the entire library to describe the results of: - [dimension equation](../../appendix/glossary.md#dimension-equation) - the result is put into @@ -169,7 +169,7 @@ constexpr auto my_unit = one / second; constexpr auto my_unit = inverse(second); ``` - Both cases will result in the same expression template being generated and put into the wrapper + Both cases will result in the same symbolic expression being generated and put into the wrapper class template. @@ -195,10 +195,10 @@ its unique representation in the library: | `sqrt({identity})` or `pow<1, 2>({identity})` | `{identity}` | -### Simplifying the resulting expression templates +### Simplifying the resulting symbolic expressions To limit the length and improve the readability of generated types, there are many rules to simplify -the resulting expression template. +the resulting symbolic expression. 1. **Ordering** @@ -246,7 +246,7 @@ the resulting expression template. Also, to prevent possible issues in compile-time logic, all of the library's entities must be marked `final`. This prevents the users to derive own strong types from them, which would - prevent expression template simplification of equivalent entities. + prevent symbolic expression simplification of equivalent entities. 4. **Repacking** diff --git a/docs/users_guide/framework_basics/systems_of_units.md b/docs/users_guide/framework_basics/systems_of_units.md index 2dea4b76..dcbc9790 100644 --- a/docs/users_guide/framework_basics/systems_of_units.md +++ b/docs/users_guide/framework_basics/systems_of_units.md @@ -96,7 +96,7 @@ All of the above quantities are equivalent and mean exactly the same. The above code example may give the impression that the order of components in a derived unit is determined by the multiplication order. This is not the case. As stated in - [Simplifying the resulting expression templates](interface_introduction.md#simplifying-the-resulting-expression-templates), + [Simplifying the resulting symbolic expressions](interface_introduction.md#simplifying-the-resulting-symbolic-expressions), to be able to reason about and simplify units, the library needs to order them in an appropriate order. This will affect the order of components in a resulting type and text output. diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6b294a4a..b1f9c89e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -55,7 +55,6 @@ add_mp_units_module( include/mp-units/framework/customization_points.h include/mp-units/framework/dimension.h include/mp-units/framework/dimension_concepts.h - include/mp-units/framework/expression_template.h include/mp-units/framework/quantity.h include/mp-units/framework/quantity_cast.h include/mp-units/framework/quantity_concepts.h @@ -67,6 +66,7 @@ add_mp_units_module( include/mp-units/framework/reference_concepts.h include/mp-units/framework/representation_concepts.h include/mp-units/framework/symbol_text.h + include/mp-units/framework/symbolic_expression.h include/mp-units/framework/system_reference.h include/mp-units/framework/unit.h include/mp-units/framework/unit_concepts.h diff --git a/src/core/include/mp-units/bits/get_associated_quantity.h b/src/core/include/mp-units/bits/get_associated_quantity.h index dc7b4211..d6140d18 100644 --- a/src/core/include/mp-units/bits/get_associated_quantity.h +++ b/src/core/include/mp-units/bits/get_associated_quantity.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace mp_units { diff --git a/src/core/include/mp-units/bits/unit_magnitude.h b/src/core/include/mp-units/bits/unit_magnitude.h index 3777c24d..0c263caf 100644 --- a/src/core/include/mp-units/bits/unit_magnitude.h +++ b/src/core/include/mp-units/bits/unit_magnitude.h @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/src/core/include/mp-units/framework.h b/src/core/include/mp-units/framework.h index ecec38bc..728ddb87 100644 --- a/src/core/include/mp-units/framework.h +++ b/src/core/include/mp-units/framework.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -39,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/include/mp-units/framework/dimension.h b/src/core/include/mp-units/framework/dimension.h index 21c77929..1e5ec03c 100644 --- a/src/core/include/mp-units/framework/dimension.h +++ b/src/core/include/mp-units/framework/dimension.h @@ -31,8 +31,8 @@ #include #include #include -#include #include +#include #ifndef MP_UNITS_IN_MODULE_INTERFACE #include @@ -122,7 +122,7 @@ struct base_dimension : detail::dimension_interface { * Derived dimension is an expression of the dependence of a quantity on the base quantities of a system of quantities * as a product of powers of factors corresponding to the base quantities, omitting any numerical factors. * - * Instead of using a raw list of exponents this library decided to use expression template syntax to make types + * Instead of using a raw list of exponents this library decided to use symbolic expression syntax to make types * more digestable for the user. The positive exponents are ordered first and all negative exponents are put as a list * into the `per<...>` class template. If a power of exponent is different than `1` the dimension type is enclosed in * `power` class template. Otherwise, it is just put directly in the list without any wrapper. There diff --git a/src/core/include/mp-units/framework/dimension_concepts.h b/src/core/include/mp-units/framework/dimension_concepts.h index 28914f9a..8b868b87 100644 --- a/src/core/include/mp-units/framework/dimension_concepts.h +++ b/src/core/include/mp-units/framework/dimension_concepts.h @@ -25,8 +25,8 @@ // IWYU pragma: private, include #include #include -#include #include +#include namespace mp_units { diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index 54437067..5342eb45 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -32,11 +32,11 @@ #include #include #include -#include #include #include #include #include +#include #ifndef MP_UNITS_IN_MODULE_INTERFACE #ifdef MP_UNITS_IMPORT_STD @@ -439,7 +439,7 @@ struct derived_quantity_spec_impl : * Its dimension is an expression of the dependence of a quantity on the base quantities of a system of * quantities as a product of powers of factors corresponding to the base quantities, omitting any numerical factors. * - * Instead of using a raw list of exponents this library decided to use expression template syntax to make types + * Instead of using a raw list of exponents this library decided to use symbolic expression syntax to make types * more digestable for the user both for quantity specification and its dimension. The positive exponents are ordered * first and all negative exponents are put as a list into the `per<...>` class template. If a power of exponent * is different than `1` the quantity type is enclosed in `power` class template. Otherwise, it is diff --git a/src/core/include/mp-units/framework/quantity_spec_concepts.h b/src/core/include/mp-units/framework/quantity_spec_concepts.h index 02caaa47..110e52eb 100644 --- a/src/core/include/mp-units/framework/quantity_spec_concepts.h +++ b/src/core/include/mp-units/framework/quantity_spec_concepts.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include namespace mp_units { diff --git a/src/core/include/mp-units/framework/expression_template.h b/src/core/include/mp-units/framework/symbolic_expression.h similarity index 100% rename from src/core/include/mp-units/framework/expression_template.h rename to src/core/include/mp-units/framework/symbolic_expression.h diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index 132b5fd3..6dc14409 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -33,10 +33,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include diff --git a/src/core/include/mp-units/framework/unit_concepts.h b/src/core/include/mp-units/framework/unit_concepts.h index b9c96866..86ff5e28 100644 --- a/src/core/include/mp-units/framework/unit_concepts.h +++ b/src/core/include/mp-units/framework/unit_concepts.h @@ -24,9 +24,9 @@ // IWYU pragma: private, include #include -#include #include #include +#include #include namespace mp_units { diff --git a/src/core/include/mp-units/framework/unit_magnitude_concepts.h b/src/core/include/mp-units/framework/unit_magnitude_concepts.h index 889a0074..a7c76bed 100644 --- a/src/core/include/mp-units/framework/unit_magnitude_concepts.h +++ b/src/core/include/mp-units/framework/unit_magnitude_concepts.h @@ -25,8 +25,8 @@ // IWYU pragma: private, include #include #include -#include #include +#include #ifndef MP_UNITS_IN_MODULE_INTERFACE #ifdef MP_UNITS_IMPORT_STD