From d4f41bb5133e12b55802db62442b72d289a5ac44 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 17 Feb 2024 23:00:23 +0100 Subject: [PATCH 1/3] refactor: `_min_cppstd` replaced with an inlined version --- conanfile.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/conanfile.py b/conanfile.py index 00639cc0..77793105 100644 --- a/conanfile.py +++ b/conanfile.py @@ -74,10 +74,6 @@ class MPUnitsConan(ConanFile): package_type = "header-library" no_copy_source = True - @property - def _min_cppstd(self): - return "20" - @property def _minimum_compilers_version(self): return { @@ -123,7 +119,7 @@ class MPUnitsConan(ConanFile): self.test_requires("wg21-linear_algebra/0.7.3") def validate(self): - check_min_cppstd(self, self._min_cppstd) + check_min_cppstd(self, "20") def loose_lt_semver(v1, v2): lv1 = [int(v) for v in v1.split(".")] From 792bd2c191d3d936070dad9d098716b78ea35193 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Sat, 17 Feb 2024 23:02:00 +0100 Subject: [PATCH 2/3] style: small formatting cleanup of `conanfile.py` --- conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conanfile.py b/conanfile.py index 77793105..74a0c960 100644 --- a/conanfile.py +++ b/conanfile.py @@ -62,15 +62,15 @@ class MPUnitsConan(ConanFile): "use_fmtlib": False, } tool_requires = "cmake/[>=3.28.1]" - exports = ["LICENSE.md"] - exports_sources = [ + exports = "LICENSE.md" + exports_sources = ( "docs/*", "src/*", "test/*", "cmake/*", "example/*", "CMakeLists.txt", - ] + ) package_type = "header-library" no_copy_source = True From f81e9bdcfe27ff289bb9212082020365889d5194 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Tue, 20 Feb 2024 19:49:22 +0100 Subject: [PATCH 3/3] refactor: `kind_of_` refactored to take a type to improve error messages --- .../mp-units/bits/quantity_spec_concepts.h | 4 +-- src/core/include/mp-units/quantity_spec.h | 28 +++++++++---------- test/static/quantity_spec_test.cpp | 20 ++++++------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/core/include/mp-units/bits/quantity_spec_concepts.h b/src/core/include/mp-units/bits/quantity_spec_concepts.h index 9ee2b690..6ddff15c 100644 --- a/src/core/include/mp-units/bits/quantity_spec_concepts.h +++ b/src/core/include/mp-units/bits/quantity_spec_concepts.h @@ -34,7 +34,7 @@ template #endif struct quantity_spec; -template +template struct kind_of_; namespace detail { @@ -42,7 +42,7 @@ namespace detail { template inline constexpr bool is_specialization_of_kind_of = false; -template +template inline constexpr bool is_specialization_of_kind_of> = true; template diff --git a/src/core/include/mp-units/quantity_spec.h b/src/core/include/mp-units/quantity_spec.h index 2b25b8a7..15e87547 100644 --- a/src/core/include/mp-units/quantity_spec.h +++ b/src/core/include/mp-units/quantity_spec.h @@ -450,30 +450,28 @@ template } // namespace detail #ifdef __cpp_explicit_this_parameter -template - requires(detail::QuantitySpecWithNoSpecifiers>) && - (detail::get_kind_tree_root(Q) == Q) -struct kind_of_ : std::remove_const_t { - static constexpr auto _quantity_spec_ = Q; +template + requires detail::QuantitySpecWithNoSpecifiers && (detail::get_kind_tree_root(Q{}) == Q{}) +struct kind_of_ : Q { + static constexpr auto _quantity_spec_ = Q{}; }; #else #if MP_UNITS_COMP_CLANG -template - requires detail::QuantitySpecWithNoSpecifiers> && - (detail::get_kind_tree_root(Q) == Q) +template + requires detail::QuantitySpecWithNoSpecifiers && (detail::get_kind_tree_root(Q{}) == Q{}) #else -template - requires(detail::get_kind_tree_root(Q) == Q) +template + requires(detail::get_kind_tree_root(Q{}) == Q{}) #endif -struct kind_of_ : quantity_spec, Q> { - static constexpr auto _quantity_spec_ = Q; +struct kind_of_ : quantity_spec, Q{}> { + static constexpr auto _quantity_spec_ = Q{}; }; #endif template requires(detail::get_kind_tree_root(Q) == Q) -inline constexpr kind_of_ kind_of; +inline constexpr kind_of_> kind_of; namespace detail { @@ -601,10 +599,10 @@ template return get_complexity(Q{}); } -template +template [[nodiscard]] consteval int get_complexity(kind_of_) { - return get_complexity(Q); + return get_complexity(Q{}); } template diff --git a/test/static/quantity_spec_test.cpp b/test/static/quantity_spec_test.cpp index b845e4c8..a7e7ee65 100644 --- a/test/static/quantity_spec_test.cpp +++ b/test/static/quantity_spec_test.cpp @@ -111,10 +111,10 @@ static_assert(detail::NamedQuantitySpec); static_assert(!detail::IntermediateDerivedQuantitySpec); static_assert(!detail::QuantityKindSpec); -static_assert(QuantitySpec>); -static_assert(!detail::NamedQuantitySpec>); -static_assert(!detail::IntermediateDerivedQuantitySpec>); -static_assert(detail::QuantityKindSpec>); +static_assert(QuantitySpec>); +static_assert(!detail::NamedQuantitySpec>); +static_assert(!detail::IntermediateDerivedQuantitySpec>); +static_assert(detail::QuantityKindSpec>); static_assert(QuantitySpec); static_assert(detail::NamedQuantitySpec); @@ -126,10 +126,10 @@ static_assert(!detail::NamedQuantitySpec); static_assert(detail::IntermediateDerivedQuantitySpec); static_assert(!detail::QuantityKindSpec); -static_assert(QuantitySpec>); -static_assert(!detail::NamedQuantitySpec>); -static_assert(detail::IntermediateDerivedQuantitySpec>); -static_assert(detail::QuantityKindSpec>); +static_assert(QuantitySpec>>); +static_assert(!detail::NamedQuantitySpec>>); +static_assert(detail::IntermediateDerivedQuantitySpec>>); +static_assert(detail::QuantityKindSpec>>); static_assert(QuantitySpec / kind_of