Merge branch 'master' of github.com:mpusz/units

This commit is contained in:
Mateusz Pusz
2024-02-20 19:59:53 +01:00
4 changed files with 29 additions and 35 deletions

View File

@@ -62,22 +62,18 @@ class MPUnitsConan(ConanFile):
"use_fmtlib": False, "use_fmtlib": False,
} }
tool_requires = "cmake/[>=3.28.1]" tool_requires = "cmake/[>=3.28.1]"
exports = ["LICENSE.md"] exports = "LICENSE.md"
exports_sources = [ exports_sources = (
"docs/*", "docs/*",
"src/*", "src/*",
"test/*", "test/*",
"cmake/*", "cmake/*",
"example/*", "example/*",
"CMakeLists.txt", "CMakeLists.txt",
] )
package_type = "header-library" package_type = "header-library"
no_copy_source = True no_copy_source = True
@property
def _min_cppstd(self):
return "20"
@property @property
def _minimum_compilers_version(self): def _minimum_compilers_version(self):
return { return {
@@ -123,7 +119,7 @@ class MPUnitsConan(ConanFile):
self.test_requires("wg21-linear_algebra/0.7.3") self.test_requires("wg21-linear_algebra/0.7.3")
def validate(self): def validate(self):
check_min_cppstd(self, self._min_cppstd) check_min_cppstd(self, "20")
def loose_lt_semver(v1, v2): def loose_lt_semver(v1, v2):
lv1 = [int(v) for v in v1.split(".")] lv1 = [int(v) for v in v1.split(".")]

View File

@@ -34,7 +34,7 @@ template<typename, auto...>
#endif #endif
struct quantity_spec; struct quantity_spec;
template<auto Q> template<typename Q>
struct kind_of_; struct kind_of_;
namespace detail { namespace detail {
@@ -42,7 +42,7 @@ namespace detail {
template<typename T> template<typename T>
inline constexpr bool is_specialization_of_kind_of = false; inline constexpr bool is_specialization_of_kind_of = false;
template<auto Q> template<typename Q>
inline constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true; inline constexpr bool is_specialization_of_kind_of<kind_of_<Q>> = true;
template<typename T> template<typename T>

View File

@@ -450,30 +450,28 @@ template<QuantitySpec Q>
} // namespace detail } // namespace detail
#ifdef __cpp_explicit_this_parameter #ifdef __cpp_explicit_this_parameter
template<auto Q> template<typename Q>
requires(detail::QuantitySpecWithNoSpecifiers<std::remove_const_t<decltype(Q)>>) && requires detail::QuantitySpecWithNoSpecifiers<Q> && (detail::get_kind_tree_root(Q{}) == Q{})
(detail::get_kind_tree_root(Q) == Q) struct kind_of_<Q> : Q {
struct kind_of_<Q> : std::remove_const_t<decltype(Q)> { static constexpr auto _quantity_spec_ = Q{};
static constexpr auto _quantity_spec_ = Q;
}; };
#else #else
#if MP_UNITS_COMP_CLANG #if MP_UNITS_COMP_CLANG
template<auto Q> template<typename Q>
requires detail::QuantitySpecWithNoSpecifiers<std::remove_cvref_t<decltype(Q)>> && requires detail::QuantitySpecWithNoSpecifiers<Q> && (detail::get_kind_tree_root(Q{}) == Q{})
(detail::get_kind_tree_root(Q) == Q)
#else #else
template<detail::QuantitySpecWithNoSpecifiers auto Q> template<detail::QuantitySpecWithNoSpecifiers Q>
requires(detail::get_kind_tree_root(Q) == Q) requires(detail::get_kind_tree_root(Q{}) == Q{})
#endif #endif
struct kind_of_<Q> : quantity_spec<kind_of_<Q>, Q> { struct kind_of_<Q> : quantity_spec<kind_of_<Q>, Q{}> {
static constexpr auto _quantity_spec_ = Q; static constexpr auto _quantity_spec_ = Q{};
}; };
#endif #endif
template<detail::QuantitySpecWithNoSpecifiers auto Q> template<detail::QuantitySpecWithNoSpecifiers auto Q>
requires(detail::get_kind_tree_root(Q) == Q) requires(detail::get_kind_tree_root(Q) == Q)
inline constexpr kind_of_<Q> kind_of; inline constexpr kind_of_<std::remove_const_t<decltype(Q)>> kind_of;
namespace detail { namespace detail {
@@ -601,10 +599,10 @@ template<QuantitySpec Q, int... Ints>
return get_complexity(Q{}); return get_complexity(Q{});
} }
template<auto Q> template<typename Q>
[[nodiscard]] consteval int get_complexity(kind_of_<Q>) [[nodiscard]] consteval int get_complexity(kind_of_<Q>)
{ {
return get_complexity(Q); return get_complexity(Q{});
} }
template<QuantitySpec Q> template<QuantitySpec Q>

View File

@@ -111,10 +111,10 @@ static_assert(detail::NamedQuantitySpec<dimensionless_>);
static_assert(!detail::IntermediateDerivedQuantitySpec<dimensionless_>); static_assert(!detail::IntermediateDerivedQuantitySpec<dimensionless_>);
static_assert(!detail::QuantityKindSpec<dimensionless_>); static_assert(!detail::QuantityKindSpec<dimensionless_>);
static_assert(QuantitySpec<kind_of_<length>>); static_assert(QuantitySpec<kind_of_<length_>>);
static_assert(!detail::NamedQuantitySpec<kind_of_<length>>); static_assert(!detail::NamedQuantitySpec<kind_of_<length_>>);
static_assert(!detail::IntermediateDerivedQuantitySpec<kind_of_<length>>); static_assert(!detail::IntermediateDerivedQuantitySpec<kind_of_<length_>>);
static_assert(detail::QuantityKindSpec<kind_of_<length>>); static_assert(detail::QuantityKindSpec<kind_of_<length_>>);
static_assert(QuantitySpec<frequency_>); static_assert(QuantitySpec<frequency_>);
static_assert(detail::NamedQuantitySpec<frequency_>); static_assert(detail::NamedQuantitySpec<frequency_>);
@@ -126,10 +126,10 @@ static_assert(!detail::NamedQuantitySpec<decltype(inverse(time))>);
static_assert(detail::IntermediateDerivedQuantitySpec<decltype(inverse(time))>); static_assert(detail::IntermediateDerivedQuantitySpec<decltype(inverse(time))>);
static_assert(!detail::QuantityKindSpec<decltype(inverse(time))>); static_assert(!detail::QuantityKindSpec<decltype(inverse(time))>);
static_assert(QuantitySpec<kind_of_<length / time>>); static_assert(QuantitySpec<kind_of_<std::remove_const_t<decltype(length / time)>>>);
static_assert(!detail::NamedQuantitySpec<kind_of_<length / time>>); static_assert(!detail::NamedQuantitySpec<kind_of_<std::remove_const_t<decltype(length / time)>>>);
static_assert(detail::IntermediateDerivedQuantitySpec<kind_of_<length / time>>); static_assert(detail::IntermediateDerivedQuantitySpec<kind_of_<std::remove_const_t<decltype(length / time)>>>);
static_assert(detail::QuantityKindSpec<kind_of_<length / time>>); static_assert(detail::QuantityKindSpec<kind_of_<std::remove_const_t<decltype(length / time)>>>);
static_assert(QuantitySpec<decltype(kind_of<length> / kind_of<time>)>); static_assert(QuantitySpec<decltype(kind_of<length> / kind_of<time>)>);
static_assert(!detail::NamedQuantitySpec<decltype(kind_of<length> / kind_of<time>)>); static_assert(!detail::NamedQuantitySpec<decltype(kind_of<length> / kind_of<time>)>);
@@ -267,8 +267,8 @@ static_assert(is_of_type<acceleration * mass, derived_quantity_spec<acceleration
static_assert(is_of_type<(acceleration * mass).dimension, static_assert(is_of_type<(acceleration * mass).dimension,
derived_dimension<dim_length_, dim_mass_, per<mp_units::power<dim_time_, 2>>>>); derived_dimension<dim_length_, dim_mass_, per<mp_units::power<dim_time_, 2>>>>);
static_assert(is_of_type<kind_of<length> / kind_of<time>, kind_of_<derived_quantity_spec<length_, per<time_>>{}>>); static_assert(is_of_type<kind_of<length> / kind_of<time>, kind_of_<derived_quantity_spec<length_, per<time_>>>>);
static_assert(is_of_type<kind_of<length / time>, kind_of_<derived_quantity_spec<length_, per<time_>>{}>>); static_assert(is_of_type<kind_of<length / time>, kind_of_<derived_quantity_spec<length_, per<time_>>>>);
// power // power
static_assert(is_of_type<pow<0>(length), dimensionless_>); static_assert(is_of_type<pow<0>(length), dimensionless_>);