diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index df86be5f..9ab7c1ed 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -25,16 +25,16 @@ name: Documentation on: push: paths: - - '.github/workflows/documentation.yml' - - 'docs/**' - - 'src/**' - - 'example/**' + - ".github/workflows/documentation.yml" + - "docs/**" + - "src/**" + - "example/**" pull_request: paths: - - '.github/workflows/documentation.yml' - - 'docs/**' - - 'src/**' - - 'example/**' + - ".github/workflows/documentation.yml" + - "docs/**" + - "src/**" + - "example/**" env: CC: gcc-10 @@ -65,7 +65,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: "3.8" - name: Install Python dependencies run: | pip install -Ur docs/requirements.txt @@ -83,7 +83,7 @@ jobs: - name: Configure CMake working-directory: build run: | - cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake + cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release - name: Generate documentation working-directory: build run: | diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fc803b52..4e1072d2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -9,7 +9,7 @@ - (!) refactor: `PrefixFamily` support removed - (!) refactor: `mi(naut)` renamed to `nmi` - (!) refactor: `knot` unit helper renamed to `kn` in FPS - - (!) refactor: `knot` text symbol changed from `"knot"` to `"kn`" + - (!) refactor: `knot` text symbol changed from `"knot"` to `"kn"` - refactor: `quantity` `op+()` and `op-()` reimplemented in terms of `reference` rather then `quantity` types - refactor(example): `glide_computer` now use dimensionless quantities with `ranged_representation` as `rep` - feat: HEP system support added (thanks [@RalphSteinhagen](https://github.com/RalphSteinhagen)) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 657bbdd5..04c7fc08 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -44,6 +44,7 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_1.png" "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/downcast_2.png" "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/units.svg" + "${CMAKE_CURRENT_SOURCE_DIR}/_static/img/quantity_like.svg" "${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.md" "${CMAKE_CURRENT_SOURCE_DIR}/design.rst" "${CMAKE_CURRENT_SOURCE_DIR}/design/directories.rst" @@ -88,6 +89,7 @@ set(unitsSphinxDocs "${CMAKE_CURRENT_SOURCE_DIR}/framework/dimensions.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/quantities.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_kinds.rst" + "${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_like.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/quantity_points.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/text_output.rst" "${CMAKE_CURRENT_SOURCE_DIR}/framework/units.rst" diff --git a/docs/_static/img/quantity_like.svg b/docs/_static/img/quantity_like.svg new file mode 100644 index 00000000..bcc1c0ff --- /dev/null +++ b/docs/_static/img/quantity_like.svg @@ -0,0 +1,37 @@ +quantityquantity_pointquantity_kindquantity_point_kindRepnumber()relative()common()relative() diff --git a/docs/framework.rst b/docs/framework.rst index ba17d2e2..cacfa71b 100644 --- a/docs/framework.rst +++ b/docs/framework.rst @@ -12,6 +12,7 @@ Framework Basics :maxdepth: 2 framework/basic_concepts + framework/quantity_like framework/quantities framework/quantity_points framework/quantity_kinds diff --git a/docs/framework/quantity_like.rst b/docs/framework/quantity_like.rst new file mode 100644 index 00000000..f963fdc7 --- /dev/null +++ b/docs/framework/quantity_like.rst @@ -0,0 +1,51 @@ +.. namespace:: units + +Quantity-like Types +=================== + +.. raw:: html + + + +.. + https://www.planttext.com + + @startuml + + skinparam monochrome true + skinparam shadowing false + skinparam backgroundColor #fcfcfc + + hide members + hide circle + + class quantity [[../framework/quantities.html]] + class quantity_point [[../framework/quantity_points.html]] + class quantity_kind [[../framework/quantity_kinds.html]] + class quantity_point_kind [[../framework/quantity_kinds.html#quantity-point-kinds]] + + Rep <-- quantity : number() + quantity <-- quantity_point : relative() + quantity <-- quantity_kind : common() + quantity_kind <-- quantity_point_kind : relative() + + @enduml + + +[ISO80000]_ defines a :term:`quantity` as a: + + Property of a phenomenon, body, or substance, where the property has a magnitude that can be expressed by + means of a number and a reference. + +You can use `quantity::number()` member function to get a concrete amount of a unit expressed with a specific +representation type ``Rep``. + +:term:`Kind of quantity ` is defined as: + + Aspect common to mutually comparable quantities. + +We can obtain a `quantity` with a `quantity_kind::common()` member function. + +`quantity_point` and `quantity_point_kind` are absolute quantities and quantity kinds relative to some +specific origin. `quantity` and `quantity_point` types can be obtained from them using a ``relative()`` member +function (`quantity_point::relative()`, `quantity_point_kind::relative()`). diff --git a/docs/framework/units.rst b/docs/framework/units.rst index 8f9fd6aa..f9981ba5 100644 --- a/docs/framework/units.rst +++ b/docs/framework/units.rst @@ -206,26 +206,26 @@ complete list of all the :term:`SI` prefixes supported by the library:: namespace si { - struct yocto : units::prefix {}; - struct zepto : units::prefix {}; - struct atto : units::prefix {}; - struct femto : units::prefix {}; - struct pico : units::prefix {}; - struct nano : units::prefix {}; - struct micro : units::prefix {}; - struct milli : units::prefix {}; - struct centi : units::prefix {}; - struct deci : units::prefix {}; - struct deca : units::prefix {}; - struct hecto : units::prefix {}; - struct kilo : units::prefix {}; - struct mega : units::prefix {}; - struct giga : units::prefix {}; - struct tera : units::prefix {}; - struct peta : units::prefix {}; - struct exa : units::prefix {}; - struct zetta : units::prefix {}; - struct yotta : units::prefix {}; + struct yocto : prefix {}; + struct zepto : prefix {}; + struct atto : prefix {}; + struct femto : prefix {}; + struct pico : prefix {}; + struct nano : prefix {}; + struct micro : prefix {}; + struct milli : prefix {}; + struct centi : prefix {}; + struct deci : prefix {}; + struct deca : prefix {}; + struct hecto : prefix {}; + struct kilo : prefix {}; + struct mega : prefix {}; + struct giga : prefix {}; + struct tera : prefix {}; + struct peta : prefix {}; + struct exa : prefix {}; + struct zetta : prefix {}; + struct yotta : prefix {}; } @@ -234,12 +234,12 @@ domain:: namespace iec80000 { - struct kibi : units::prefix {}; - struct mebi : units::prefix {}; - struct gibi : units::prefix {}; - struct tebi : units::prefix {}; - struct pebi : units::prefix {}; - struct exbi : units::prefix {}; + struct kibi : prefix {}; + struct mebi : prefix {}; + struct gibi : prefix {}; + struct tebi : prefix {}; + struct pebi : prefix {}; + struct exbi : prefix {}; } @@ -301,15 +301,15 @@ will result in a different unnamed unit symbol: struct dim_momentum : derived_dimension, exponent, - exponent> {}; // kg ⋅ m/s + exponent> {}; // kg⋅m/s struct dim_momentum : derived_dimension, exponent, - exponent> {}; // m ⋅ kg/s + exponent> {}; // m⋅kg/s struct dim_momentum : derived_dimension, exponent, - exponent> {}; // 1/s ⋅ m ⋅ kg + exponent> {}; // 1/s⋅m⋅kg where ``kilogram_metre_per_second`` is defined as:: @@ -323,7 +323,7 @@ However, the easiest way to define momentum is just to use the struct dim_momentum : derived_dimension, - exponent> {}; // kg ⋅ m/s + exponent> {}; // kg⋅m/s In such a case the library will do its magic and will automatically unpack a provided derived dimension to its base dimensions in order to diff --git a/docs/usage.rst b/docs/usage.rst index bde4ea77..9e1ebe10 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -212,8 +212,8 @@ only a few of many options possible. Copy ^^^^ -As **mp-units** is a C++ header-only library you can simply copy *src/include* directory to -your source tree and use it as regular header files. +As **mp-units** is a C++ header-only library you can simply copy all needed ``src/*/include`` subdirectories +to your source tree. .. important:: diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 76117aa4..6733348b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -37,6 +37,7 @@ add_example(conversion_factor mp-units::core-fmt mp-units::core-io mp-units::si) add_example(custom_systems mp-units::core-io mp-units::si) add_example(hello_units mp-units::core-fmt mp-units::core-io mp-units::si mp-units::si-international) add_example(measurement mp-units::core-io mp-units::si) +add_example(si_constants mp-units::core-fmt mp-units::si) if(NOT ${projectPrefix}LIBCXX) add_subdirectory(glide_computer) diff --git a/example/kalman_filter/kalman.h b/example/kalman_filter/kalman.h index a034d2db..f878335b 100644 --- a/example/kalman_filter/kalman.h +++ b/example/kalman_filter/kalman.h @@ -38,20 +38,20 @@ concept QuantityOrQuantityPoint = units::Quantity || units::QuantityPoint; // TODO Should it also account for `kinds`? template -inline constexpr bool are_derivatives = false; +inline constexpr bool are_time_derivatives = false; template -inline constexpr bool are_derivatives = true; +inline constexpr bool are_time_derivatives = true; template -inline constexpr bool are_derivatives = +inline constexpr bool are_time_derivatives = units::DimensionOfT && // TODO Think on how to simplify this - are_derivatives; + are_time_derivatives; // state template - requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_derivatives + requires(sizeof...(QQPs) > 0) && (sizeof...(QQPs) <= 3) && are_time_derivatives struct state { std::tuple variables_; constexpr state(QQPs... qqps) : variables_(std::move(qqps)...) {} diff --git a/example/si_constants.cpp b/example/si_constants.cpp new file mode 100644 index 00000000..c3c9ccf2 --- /dev/null +++ b/example/si_constants.cpp @@ -0,0 +1,40 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include +#include +#include + +int main() +{ + using namespace units::isq::si::si2019; + + std::cout << "The seven defining constants of the SI and the seven corresponding units they define:\n"; + std::cout << STD_FMT::format("- hyperfine transition frequency of Cs: {:%.0Q %q}\n", + hyperfine_structure_transition_frequency<>); + std::cout << STD_FMT::format("- speed of light in vacuum: {:%.0Q %q}\n", speed_of_light<>); + std::cout << STD_FMT::format("- Planck constant: {}\n", planck_constant<>); + std::cout << STD_FMT::format("- elementary charge: {}\n", elementary_charge<>); + std::cout << STD_FMT::format("- Boltzmann constant: {}\n", boltzmann_constant<>); + std::cout << STD_FMT::format("- Avogadro constant: {}\n", avogadro_constant<>); + std::cout << STD_FMT::format("- luminous efficacy: {}\n", luminous_efficacy<>); +} diff --git a/src/core/include/units/bits/derived_scaled_unit.h b/src/core/include/units/bits/derived_scaled_unit.h index 60e9e506..5a8b4cd7 100644 --- a/src/core/include/units/bits/derived_scaled_unit.h +++ b/src/core/include/units/bits/derived_scaled_unit.h @@ -27,12 +27,12 @@ namespace units::detail { -// same_scaled_units +// compatible_units template -inline constexpr bool same_scaled_units = false; +inline constexpr bool compatible_units = false; template -inline constexpr bool same_scaled_units, Us...> = (UnitOf && ...); +inline constexpr bool compatible_units, Us...> = (UnitOf && ...); // derived_scaled_unit diff --git a/src/core/include/units/bits/derived_symbol_text.h b/src/core/include/units/bits/derived_symbol_text.h index 10a08de3..2d358725 100644 --- a/src/core/include/units/bits/derived_symbol_text.h +++ b/src/core/include/units/bits/derived_symbol_text.h @@ -42,7 +42,7 @@ constexpr auto operator_text() if constexpr (Divide && NegativeExpCount == 1) { return basic_fixed_string("/"); } else { - return basic_symbol_text(" ⋅ ", " "); + return basic_symbol_text("⋅", " "); } } } diff --git a/src/core/include/units/quantity.h b/src/core/include/units/quantity.h index 8b286259..6f9f9d0c 100644 --- a/src/core/include/units/quantity.h +++ b/src/core/include/units/quantity.h @@ -449,6 +449,9 @@ template explicit(false) quantity(Rep&&)->quantity; #endif +template +explicit(false) quantity(quantity)->quantity; + template explicit(false) quantity(Rep)->quantity; diff --git a/src/core/include/units/unit.h b/src/core/include/units/unit.h index 3e4f7253..52b9779c 100644 --- a/src/core/include/units/unit.h +++ b/src/core/include/units/unit.h @@ -142,7 +142,7 @@ struct derived_unit : downcast_dispatch(), Ch * @tparam URest the units for the rest of dimensions from the recipe */ template - requires detail::same_scaled_units + requires detail::compatible_units struct derived_scaled_unit : downcast_dispatch> { static constexpr auto symbol = detail::derived_symbol_text(); }; diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h index 1ff0679e..f5e472ef 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h @@ -26,11 +26,11 @@ namespace units::isq::iec80000 { -struct kibi : units::prefix {}; -struct mebi : units::prefix {}; -struct gibi : units::prefix {}; -struct tebi : units::prefix {}; -struct pebi : units::prefix {}; -struct exbi : units::prefix {}; +struct kibi : prefix {}; +struct mebi : prefix {}; +struct gibi : prefix {}; +struct tebi : prefix {}; +struct pebi : prefix {}; +struct exbi : prefix {}; } // namespace units::isq::iec80000 diff --git a/src/systems/isq/CMakeLists.txt b/src/systems/isq/CMakeLists.txt index c7dffcfc..bb575c65 100644 --- a/src/systems/isq/CMakeLists.txt +++ b/src/systems/isq/CMakeLists.txt @@ -49,6 +49,7 @@ add_units_module( include/units/isq/dimensions/inductance.h include/units/isq/dimensions/length.h include/units/isq/dimensions/luminance.h + include/units/isq/dimensions/luminous_flux.h include/units/isq/dimensions/luminous_intensity.h include/units/isq/dimensions/magnetic_flux.h include/units/isq/dimensions/magnetic_induction.h diff --git a/src/systems/isq/include/units/isq/dimensions.h b/src/systems/isq/include/units/isq/dimensions.h index a4e8dd1d..4983390c 100644 --- a/src/systems/isq/include/units/isq/dimensions.h +++ b/src/systems/isq/include/units/isq/dimensions.h @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include diff --git a/src/systems/isq/include/units/isq/dimensions/luminous_flux.h b/src/systems/isq/include/units/isq/dimensions/luminous_flux.h new file mode 100644 index 00000000..a86a6285 --- /dev/null +++ b/src/systems/isq/include/units/isq/dimensions/luminous_flux.h @@ -0,0 +1,36 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include +#include + +namespace units::isq { + +template +using dim_luminous_flux = dim_power; + +template +concept LuminousFlux = QuantityOfT; + +} // namespace units::isq diff --git a/src/systems/si/CMakeLists.txt b/src/systems/si/CMakeLists.txt index f591c780..052d6d3c 100644 --- a/src/systems/si/CMakeLists.txt +++ b/src/systems/si/CMakeLists.txt @@ -50,6 +50,7 @@ add_units_module( include/units/isq/si/inductance.h include/units/isq/si/length.h include/units/isq/si/luminance.h + include/units/isq/si/luminous_flux.h include/units/isq/si/luminous_intensity.h include/units/isq/si/magnetic_flux.h include/units/isq/si/magnetic_induction.h diff --git a/src/systems/si/include/units/isq/si/constants.h b/src/systems/si/include/units/isq/si/constants.h index a0097532..79884577 100644 --- a/src/systems/si/include/units/isq/si/constants.h +++ b/src/systems/si/include/units/isq/si/constants.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -51,10 +52,10 @@ template inline constexpr auto speed_of_light = speed(299'792'458); template -inline constexpr auto hyperfine_structure_transition_frequency = frequency(9'192'631'770); +inline constexpr auto hyperfine_structure_transition_frequency = frequency(Rep{9'192'631'770}); -// template -// inline constexpr auto luminous_efficacy = 683_q_lm / 1_q_W; +template +inline constexpr auto luminous_efficacy = luminous_flux(683) / power(1); template inline constexpr auto standard_gravity = acceleration(9.80665); diff --git a/src/systems/si/include/units/isq/si/luminous_flux.h b/src/systems/si/include/units/isq/si/luminous_flux.h new file mode 100644 index 00000000..7d9592e3 --- /dev/null +++ b/src/systems/si/include/units/isq/si/luminous_flux.h @@ -0,0 +1,89 @@ +// The MIT License (MIT) +// +// Copyright (c) 2018 Mateusz Pusz +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +// IWYU pragma: begin_exports +#include +#include +#include +#include +// IWYU pragma: end_exports + +#include +#include + +namespace units::isq::si { + +// TODO Is this correct? Should we account for steradian here? How? + +struct lumen : named_scaled_unit {}; + +using dim_luminous_flux = dim_power; + +template U, Representation Rep = double> +using luminous_flux = power; + +#ifndef UNITS_NO_LITERALS + +inline namespace literals { + +// lm +constexpr auto operator"" _q_lm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return luminous_flux(static_cast(l)); +} +constexpr auto operator"" _q_lm(long double l) { return luminous_flux(l); } + +} // namespace literals + +#endif // UNITS_NO_LITERALS + +#ifndef UNITS_NO_REFERENCES + +namespace luminous_flux_references { + +inline constexpr auto lm = reference{}; + +} // namespace luminous_flux_references + +namespace references { + +using namespace luminous_flux_references; + +} // namespace references + +#endif // UNITS_NO_REFERENCES + +} // namespace units::isq::si + +#ifndef UNITS_NO_ALIASES + +namespace units::aliases::isq::si::inline luminous_flux { + +template +using lm = units::isq::si::luminous_flux; + +} // namespace units::aliases::isq::si::inline luminous_flux + +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/prefixes.h b/src/systems/si/include/units/isq/si/prefixes.h index 0efabcf3..81f7c553 100644 --- a/src/systems/si/include/units/isq/si/prefixes.h +++ b/src/systems/si/include/units/isq/si/prefixes.h @@ -27,26 +27,26 @@ namespace units::isq::si { // clang-format off -struct yocto : units::prefix {}; -struct zepto : units::prefix {}; -struct atto : units::prefix {}; -struct femto : units::prefix {}; -struct pico : units::prefix {}; -struct nano : units::prefix {}; -struct micro : units::prefix {}; -struct milli : units::prefix {}; -struct centi : units::prefix {}; -struct deci : units::prefix {}; -struct deca : units::prefix {}; -struct hecto : units::prefix {}; -struct kilo : units::prefix {}; -struct mega : units::prefix {}; -struct giga : units::prefix {}; -struct tera : units::prefix {}; -struct peta : units::prefix {}; -struct exa : units::prefix {}; -struct zetta : units::prefix {}; -struct yotta : units::prefix {}; +struct yocto : prefix {}; +struct zepto : prefix {}; +struct atto : prefix {}; +struct femto : prefix {}; +struct pico : prefix {}; +struct nano : prefix {}; +struct micro : prefix {}; +struct milli : prefix {}; +struct centi : prefix {}; +struct deci : prefix {}; +struct deca : prefix {}; +struct hecto : prefix {}; +struct kilo : prefix {}; +struct mega : prefix {}; +struct giga : prefix {}; +struct tera : prefix {}; +struct peta : prefix {}; +struct exa : prefix {}; +struct zetta : prefix {}; +struct yotta : prefix {}; // clang-format on } // namespace units::isq::si diff --git a/src/systems/si/include/units/isq/si/si.h b/src/systems/si/include/units/isq/si/si.h index 6a0d03c9..369d6f3d 100644 --- a/src/systems/si/include/units/isq/si/si.h +++ b/src/systems/si/include/units/isq/si/si.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -40,35 +41,37 @@ #include #include #include -#include -#include -#include -#include -#include -// TODO Add when downcasting issue is solved (collides with pressure) -// #include #include #include #include #include +#include #include +#include +#include #include #include +#include #include #include #include #include #include -#include -// TODO Add when downcasting issue is solved (collides with frequency) -// #include -#include #include +#include #include #include #include #include +#include +#include #include #include #include // IWYU pragma: end_exports + +// TODO Add when downcasting issue is solved (collides with pressure) +// #include + +// TODO Add when downcasting issue is solved (collides with frequency) +// #include diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index 3f729638..7cc0f748 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -318,7 +318,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_s * 2_q_m * 2_q_kg; os << q; - SECTION("iostream") { CHECK(os.str() == "8 m ⋅ kg ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "8 m⋅kg⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -330,7 +330,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2._q_s * si::cgs::length(2) * si::cgs::mass(2); os << q; - SECTION("iostream") { CHECK(os.str() == "8 cm ⋅ g ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "8 cm⋅g⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -343,7 +343,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_km * 2_q_s; os << q; - SECTION("iostream") { CHECK(os.str() == "8 × 10³ m ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "8 × 10³ m⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -379,7 +379,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2._q_s * si::cgs::length(2) * si::cgs::mass(2); os << q; - SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm ⋅ g ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm⋅g⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -404,7 +404,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_m * 2_q_s; os << q; - SECTION("iostream") { CHECK(os.str() == "8 m ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "8 m⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -416,7 +416,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_m * 2_q_s * 2_q_s; os << q; - SECTION("iostream") { CHECK(os.str() == "16 m ⋅ s²"); } + SECTION("iostream") { CHECK(os.str() == "16 m⋅s²"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } @@ -428,7 +428,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 8_q_s / 2_q_m / 2_q_m; os << q; - SECTION("iostream") { CHECK(os.str() == "2 1/m² ⋅ s"); } + SECTION("iostream") { CHECK(os.str() == "2 1/m²⋅s"); } SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 58531174..0f611eed 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -167,7 +167,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") SECTION("momentum") { - CHECK(STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg ⋅ m/s"); + CHECK(STD_FMT::format("{}", 1_q_kg_m_per_s) == "1 kg⋅m/s"); CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_kg_m_per_s) == "1 kg m/s"); } @@ -244,7 +244,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") SECTION("dynamic viscosity") { - CHECK(STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa ⋅ s"); + CHECK(STD_FMT::format("{}", 1_q_Pa_s) == "1 Pa⋅s"); CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_Pa_s) == "1 Pa s"); } @@ -252,19 +252,19 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") SECTION("specific heat capacity") { - CHECK(STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J ⋅ K⁻¹ ⋅ kg⁻¹"); + CHECK(STD_FMT::format("{}", 1_q_J_per_kg_K) == "1 J⋅K⁻¹⋅kg⁻¹"); CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_kg_K) == "1 J K^-1 kg^-1"); } SECTION("molar heath capacity") { - CHECK(STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J ⋅ K⁻¹ ⋅ mol⁻¹"); + CHECK(STD_FMT::format("{}", 1_q_J_per_mol_K) == "1 J⋅K⁻¹⋅mol⁻¹"); CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_J_per_mol_K) == "1 J K^-1 mol^-1"); } SECTION("thermal conductivity") { - CHECK(STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W ⋅ m⁻¹ ⋅ K⁻¹"); + CHECK(STD_FMT::format("{}", 1_q_W_per_m_K) == "1 W⋅m⁻¹⋅K⁻¹"); CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_W_per_m_K) == "1 W m^-1 K^-1"); } @@ -284,7 +284,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") SECTION("molar energy") { CHECK(STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); } - SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N ⋅ m/rad"); } + SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N⋅m/rad"); } SECTION("storage_capacity") { diff --git a/test/unit_test/static/fps_test.cpp b/test/unit_test/static/fps_test.cpp index 4304f120..774971e7 100644 --- a/test/unit_test/static/fps_test.cpp +++ b/test/unit_test/static/fps_test.cpp @@ -88,8 +88,8 @@ static_assert(10_q_pdl * 10_q_ft == 100_q_ft_pdl); static_assert(100_q_ft_pdl / 10_q_ft == 10_q_pdl); static_assert(100_q_ft_pdl / 10_q_pdl == 10_q_ft); -static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ pdl", "ft pdl")); -static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ lbf", "ft lbf")); +static_assert(detail::unit_text() == basic_symbol_text("ft⋅pdl", "ft pdl")); +static_assert(detail::unit_text() == basic_symbol_text("ft⋅lbf", "ft lbf")); /* ************** DERIVED DIMENSIONS IN TERMS OF OTHER UNITS **************** */ @@ -99,8 +99,8 @@ static_assert(10_q_ft_pdl / 10_q_s == 1_q_ft_pdl_per_s); static_assert(1_q_ft_pdl_per_s * 10_q_s == 10_q_ft_pdl); static_assert(10_q_ft_pdl / 1_q_ft_pdl_per_s == 10_q_s); -static_assert(detail::unit_text() == basic_symbol_text("ft ⋅ pdl/s", "ft pdl/s")); +static_assert(detail::unit_text() == basic_symbol_text("ft⋅pdl/s", "ft pdl/s")); static_assert(detail::unit_text() == - basic_symbol_text("ft ⋅ lbf/s", "ft lbf/s")); + basic_symbol_text("ft⋅lbf/s", "ft lbf/s")); } // namespace diff --git a/test/unit_test/static/quantity_test.cpp b/test/unit_test/static/quantity_test.cpp index 1c0ad9d2..cf346a27 100644 --- a/test/unit_test/static/quantity_test.cpp +++ b/test/unit_test/static/quantity_test.cpp @@ -288,8 +288,10 @@ static_assert(get_length_derived_quantity() == 1_q_m); ///////// #if UNITS_COMP_GCC >= 11 || UNITS_COMP_CLANG > 15 -static_assert(std::is_same_v); -static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert(std::is_same_v); +static_assert( + std::is_same_v); #endif static_assert(is_same_v(123)}), length>); diff --git a/test/unit_test/static/si_test.cpp b/test/unit_test/static/si_test.cpp index bbd81a8e..02960463 100644 --- a/test/unit_test/static/si_test.cpp +++ b/test/unit_test/static/si_test.cpp @@ -239,6 +239,12 @@ static_assert(gray::symbol == "Gy"); static_assert(milligray::symbol == "mGy"); static_assert(kilogray::symbol == "kGy"); +// luminous flux + +static_assert(683_q_lm == 1_q_W); + +static_assert(lumen::symbol == "lm"); + /* ************** DERIVED DIMENSIONS IN TERMS OF BASE UNITS **************** */ // speed @@ -334,7 +340,7 @@ static_assert(detail::unit_text() == basic_ // dynamic viscosity static_assert(1_q_Pa_s == 1_q_N * 1_q_s / 1_q_m2); -static_assert(detail::unit_text() == basic_symbol_text("Pa ⋅ s", "Pa s")); +static_assert(detail::unit_text() == basic_symbol_text("Pa⋅s", "Pa s")); // [specific|molar] heath capacity @@ -344,13 +350,13 @@ static_assert(1_q_J_per_mol_K == 1_q_J_per_K / 1_q_mol); static_assert(detail::unit_text() == "J/K"); static_assert(detail::unit_text() == - basic_symbol_text("J ⋅ K⁻¹ ⋅ kg⁻¹", "J K^-1 kg^-1")); + basic_symbol_text("J⋅K⁻¹⋅kg⁻¹", "J K^-1 kg^-1")); // thermal conductivity static_assert(20_q_W_per_m_K * 10_q_m * 300_q_K == 60'000_q_W); static_assert(detail::unit_text() == - basic_symbol_text("W ⋅ m⁻¹ ⋅ K⁻¹", "W m^-1 K^-1")); + basic_symbol_text("W⋅m⁻¹⋅K⁻¹", "W m^-1 K^-1")); // electric field strength diff --git a/test_package/conanfile.py b/test_package/conanfile.py index 1afb178a..4f4506f5 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -21,8 +21,8 @@ # SOFTWARE. from conan import ConanFile -from conan.tools.cmake import CMake from conan.tools.build import cross_building +from conan.tools.cmake import CMake class TestPackageConan(ConanFile):