From 0b0d3345e59b440895c2ac12a2e294e64fe2157c Mon Sep 17 00:00:00 2001 From: Jonas Hoppe <162709928+czjhoppe@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:17:44 +0200 Subject: [PATCH] [clang-format] --- example/total_energy.cpp | 4 +- src/core/include/mp-units/bits/fmt.h | 8 +- src/core/include/mp-units/bits/hacks.h | 3 +- src/core/include/mp-units/bits/sudo_cast.h | 13 +- src/core/include/mp-units/format.h | 2 +- .../mp-units/framework/construction_helpers.h | 4 +- .../include/mp-units/framework/quantity.h | 8 +- .../mp-units/framework/quantity_point.h | 9 +- .../mp-units/framework/quantity_spec.h | 28 +++-- .../include/mp-units/framework/reference.h | 32 +++-- .../include/mp-units/framework/symbol_text.h | 3 +- src/core/include/mp-units/ostream.h | 2 +- .../include/mp-units/systems/si/math.h | 4 +- test/static/chrono_test.cpp | 6 +- test/static/custom_rep_test_min_impl.cpp | 11 +- test/static/quantity_point_test.cpp | 112 ++++++++++-------- test/static/quantity_test.cpp | 31 +++-- 17 files changed, 161 insertions(+), 119 deletions(-) diff --git a/example/total_energy.cpp b/example/total_energy.cpp index f0b961b9..44fbc22c 100644 --- a/example/total_energy.cpp +++ b/example/total_energy.cpp @@ -45,8 +45,8 @@ namespace { using namespace mp_units; -QuantityOf<(isq::mechanical_energy)> auto total_energy(QuantityOf<(isq::momentum)> auto p, QuantityOf<(isq::mass)> auto m, - QuantityOf<(isq::speed)> auto c) +QuantityOf<(isq::mechanical_energy)> auto total_energy(QuantityOf<(isq::momentum)> auto p, + QuantityOf<(isq::mass)> auto m, QuantityOf<(isq::speed)> auto c) { return isq::mechanical_energy(sqrt(pow<2>(p * c) + pow<2>(m * pow<2>(c)))); } diff --git a/src/core/include/mp-units/bits/fmt.h b/src/core/include/mp-units/bits/fmt.h index 1505ce25..3589bc11 100644 --- a/src/core/include/mp-units/bits/fmt.h +++ b/src/core/include/mp-units/bits/fmt.h @@ -189,7 +189,7 @@ constexpr void handle_dynamic_spec(int& value, fmt_arg_ref(value); } - MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer")); + MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("width is not integer")); } }; -#ifdef _MSC_VER -#pragma warning( pop ) +#ifdef _MSC_VER +#pragma warning(pop) #endif MP_UNITS_EXPORT_END diff --git a/src/core/include/mp-units/bits/hacks.h b/src/core/include/mp-units/bits/hacks.h index 09a6daab..9dd88298 100644 --- a/src/core/include/mp-units/bits/hacks.h +++ b/src/core/include/mp-units/bits/hacks.h @@ -82,7 +82,8 @@ #define MP_UNITS_TYPENAME typename #define MP_UNITS_EXPRESSION(x) (x) #define MP_UNITS_IS_VALUE(x) (x) -#define MP_UNITS_IS_CONST_EXPR(x) decltype(x){} +#define MP_UNITS_IS_CONST_EXPR(x) \ + decltype(x) {} #else diff --git a/src/core/include/mp-units/bits/sudo_cast.h b/src/core/include/mp-units/bits/sudo_cast.h index 0db70246..0873fd59 100644 --- a/src/core/include/mp-units/bits/sudo_cast.h +++ b/src/core/include/mp-units/bits/sudo_cast.h @@ -30,23 +30,24 @@ namespace mp_units::detail { -template +template struct has_common_type_impl : std::false_type {}; -template +template struct has_common_type_impl>, Ts...> : std::true_type {}; -template +template using has_common_type = typename has_common_type_impl::type; -template constexpr bool has_common_type_v = has_common_type_impl::value; +template +constexpr bool has_common_type_v = has_common_type_impl::value; template struct get_common_type : std::common_type {}; template -using maybe_common_type = MP_UNITS_TYPENAME std::conditional_t, - get_common_type, std::type_identity>::type; +using maybe_common_type = MP_UNITS_TYPENAME + std::conditional_t, get_common_type, std::type_identity>::type; /** * @brief Details about the conversion from one quantity to another. diff --git a/src/core/include/mp-units/format.h b/src/core/include/mp-units/format.h index d5fea4b6..6c76b5f8 100644 --- a/src/core/include/mp-units/format.h +++ b/src/core/include/mp-units/format.h @@ -452,7 +452,7 @@ class MP_UNITS_STD_FMT::formatter, Char> { } // user provided format quantity_formatter f{*this, out, q, locale}; - parse_quantity_specs(modifiers_format_str_.data(), modifiers_format_str_.data() + modifiers_format_str_.size(), f); + parse_quantity_specs(modifiers_format_str_.data(), modifiers_format_str_.data() + modifiers_format_str_.size(), f); return f.out; } diff --git a/src/core/include/mp-units/framework/construction_helpers.h b/src/core/include/mp-units/framework/construction_helpers.h index 43e44c81..9b5f9be9 100644 --- a/src/core/include/mp-units/framework/construction_helpers.h +++ b/src/core/include/mp-units/framework/construction_helpers.h @@ -51,8 +51,8 @@ template struct absolute_ { template requires RepresentationOf, get_quantity_spec(R{}).character> - [[nodiscard]] constexpr quantity_point> operator()( - Rep&& lhs) const + [[nodiscard]] constexpr quantity_point> + operator()(Rep&& lhs) const { return quantity_point{quantity{std::forward(lhs), R{}}}; } diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index d957cb14..a5fada73 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -461,8 +461,8 @@ public: } friend constexpr decltype(auto) operator*=(Q1&& lhs, const Q2& rhs) { - lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ * - rhs.numerical_value_is_an_implementation_detail_; + lhs.numerical_value_is_an_implementation_detail_ = + lhs.numerical_value_is_an_implementation_detail_ * rhs.numerical_value_is_an_implementation_detail_; return std::forward(lhs); } @@ -490,8 +490,8 @@ public: friend constexpr decltype(auto) operator/=(Q1&& lhs, const Q2& rhs) { MP_UNITS_EXPECTS_DEBUG(rhs != rhs.zero()); - lhs.numerical_value_is_an_implementation_detail_ = lhs.numerical_value_is_an_implementation_detail_ - / rhs.numerical_value_is_an_implementation_detail_; + lhs.numerical_value_is_an_implementation_detail_ = + lhs.numerical_value_is_an_implementation_detail_ / rhs.numerical_value_is_an_implementation_detail_; return std::forward(lhs); } diff --git a/src/core/include/mp-units/framework/quantity_point.h b/src/core/include/mp-units/framework/quantity_point.h index 58b28b3f..c7d60319 100644 --- a/src/core/include/mp-units/framework/quantity_point.h +++ b/src/core/include/mp-units/framework/quantity_point.h @@ -54,14 +54,16 @@ template struct point_origin_interface { template requires ReferenceOf, PO::quantity_spec> - [[nodiscard]] friend constexpr quantity_point operator+(PO, Q&& q) + [[nodiscard]] friend constexpr quantity_point operator+( + PO, Q&& q) { return quantity_point{std::forward(q), PO{}}; } template requires ReferenceOf, PO::quantity_spec> - [[nodiscard]] friend constexpr quantity_point operator+(Q&& q, PO po) + [[nodiscard]] friend constexpr quantity_point operator+( + Q&& q, PO po) { return po + std::forward(q); } @@ -264,8 +266,7 @@ public: quantity_point& operator=(quantity_point&&) = default; template NewPO> - [[nodiscard]] constexpr QuantityPointOf<(NewPO{})> auto point_for( - NewPO new_origin) const + [[nodiscard]] constexpr QuantityPointOf<(NewPO{})> auto point_for(NewPO new_origin) const { if constexpr (is_same_v) return *this; diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index 8a3b4598..664f26fc 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -673,7 +673,8 @@ template template [[nodiscard]] consteval bool ingredients_dimension_less(D1 lhs, D2 rhs) { - if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) || MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one) + if constexpr (MP_UNITS_IS_CONST_EXPR(lhs) == MP_UNITS_IS_CONST_EXPR(rhs) || + MP_UNITS_IS_CONST_EXPR(lhs) == dimension_one) return false; else if constexpr (MP_UNITS_IS_CONST_EXPR(rhs) == dimension_one) return true; @@ -1344,15 +1345,21 @@ template using enum specs_convertible_result; return res == no ? no : yes; }; - if constexpr ((NamedQuantitySpec && NamedQuantitySpec) || + if constexpr ((NamedQuantitySpec && + NamedQuantitySpec) || get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) == get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))) return convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), MP_UNITS_IS_CONST_EXPR(to_kind)); - else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) > get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))) - return exploded_kind_result( - convertible_impl(get_kind_tree_root(explode(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity), MP_UNITS_IS_CONST_EXPR(to_kind))); + else if constexpr (get_complexity(MP_UNITS_IS_CONST_EXPR(from_kind)) > + get_complexity(MP_UNITS_IS_CONST_EXPR(to_kind))) + return exploded_kind_result(convertible_impl( + get_kind_tree_root( + explode(MP_UNITS_IS_CONST_EXPR(from_kind)).quantity), + MP_UNITS_IS_CONST_EXPR(to_kind))); else - return exploded_kind_result( - convertible_impl(MP_UNITS_IS_CONST_EXPR(from_kind), get_kind_tree_root(explode(MP_UNITS_IS_CONST_EXPR(to_kind)).quantity))); + return exploded_kind_result(convertible_impl( + MP_UNITS_IS_CONST_EXPR(from_kind), + get_kind_tree_root( + explode(MP_UNITS_IS_CONST_EXPR(to_kind)).quantity))); } template @@ -1369,7 +1376,9 @@ template return no; else if constexpr (get_complexity(From{}) != get_complexity(To{})) { if constexpr (get_complexity(From{}) > get_complexity(To{})) - return convertible_impl(explode(MP_UNITS_IS_CONST_EXPR(from)).quantity, MP_UNITS_IS_CONST_EXPR(to)); + return convertible_impl( + explode(MP_UNITS_IS_CONST_EXPR(from)).quantity, + MP_UNITS_IS_CONST_EXPR(to)); else { auto res = explode(MP_UNITS_IS_CONST_EXPR(to)); return min(res.result, convertible_impl(MP_UNITS_IS_CONST_EXPR(from), res.quantity)); @@ -1388,7 +1397,8 @@ template else if constexpr (From::dimension != To::dimension) return no; else if constexpr (QuantityKindSpec || QuantityKindSpec) - return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)), get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to))); + return convertible_kinds(get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(from)), + get_kind_tree_root(MP_UNITS_IS_CONST_EXPR(to))); else if constexpr (NestedQuantityKindSpecOf && get_kind_tree_root(To{}) == To{}) return yes; else if constexpr (NamedQuantitySpec && NamedQuantitySpec) diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index a2d3ae1a..c946476e 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -87,40 +87,47 @@ struct reference { } template - [[nodiscard]] friend consteval detail::reference_t operator*(reference, reference) + [[nodiscard]] friend consteval detail::reference_t + operator*(reference, reference) { return {}; } template - [[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))), MP_UNITS_EXPRESSION(U{} * U2{})> operator*(reference, - U2) + [[nodiscard]] friend consteval detail::reference_t<(MP_UNITS_EXPRESSION(Q{} * get_quantity_spec(U2{}))), + MP_UNITS_EXPRESSION(U{} * U2{})> + operator*(reference, U2) { return {}; } template - [[nodiscard]] friend consteval detail::reference_t operator*(U1, - reference) + [[nodiscard]] friend consteval detail::reference_t + operator*(U1, reference) { return {}; } template - [[nodiscard]] friend consteval detail::reference_t operator/(reference, reference) + [[nodiscard]] friend consteval detail::reference_t + operator/(reference, reference) { return {}; } template - [[nodiscard]] friend consteval detail::reference_t operator/(reference, - U2) + [[nodiscard]] friend consteval detail::reference_t + operator/(reference, U2) { return {}; } template - [[nodiscard]] friend consteval detail::reference_t operator/(U1, reference) + [[nodiscard]] friend consteval detail::reference_t + operator/(U1, reference) { return {}; } @@ -288,9 +295,10 @@ template } -> Unit; } { - return detail::reference_t{}; + return detail::reference_t< + common_quantity_spec(get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r1)), get_quantity_spec(MP_UNITS_IS_CONST_EXPR(r2)), + get_quantity_spec(rest)...), + common_unit(get_unit(MP_UNITS_IS_CONST_EXPR(r1)), get_unit(MP_UNITS_IS_CONST_EXPR(r2)), get_unit(rest)...)>{}; } MP_UNITS_EXPORT_END diff --git a/src/core/include/mp-units/framework/symbol_text.h b/src/core/include/mp-units/framework/symbol_text.h index 36dd4942..a08a6844 100644 --- a/src/core/include/mp-units/framework/symbol_text.h +++ b/src/core/include/mp-units/framework/symbol_text.h @@ -128,7 +128,8 @@ public: MP_UNITS_EXPECTS(detail::is_basic_literal_character_set(a)); } - constexpr symbol_text(const fixed_u8string& unicode, const fixed_string& ascii) : unicode_(unicode), ascii_(ascii) + constexpr symbol_text(const fixed_u8string& unicode, const fixed_string& ascii) : + unicode_(unicode), ascii_(ascii) { MP_UNITS_EXPECTS(detail::is_basic_literal_character_set(ascii.data_)); } diff --git a/src/core/include/mp-units/ostream.h b/src/core/include/mp-units/ostream.h index d9ba6e5d..0b073225 100644 --- a/src/core/include/mp-units/ostream.h +++ b/src/core/include/mp-units/ostream.h @@ -90,7 +90,7 @@ std::basic_ostream& to_stream(std::basic_ostream& MP_UNITS_EXPORT_BEGIN template -concept is_mp_units_stream = requires (OStream os, T v) { detail::to_stream_impl(os, v); }; +concept is_mp_units_stream = requires(OStream os, T v) { detail::to_stream_impl(os, v); }; template std::basic_ostream& operator<<(std::basic_ostream& os, const T& v) diff --git a/src/systems/include/mp-units/systems/si/math.h b/src/systems/include/mp-units/systems/si/math.h index 0a863585..a7bc0cec 100644 --- a/src/systems/include/mp-units/systems/si/math.h +++ b/src/systems/include/mp-units/systems/si/math.h @@ -132,8 +132,8 @@ template common_reference(R1, R2); requires requires { atan2(v1, v2); } || requires { std::atan2(v1, v2); }; } -[[nodiscard]] inline QuantityOf auto atan2(const quantity& y, - const quantity& x) noexcept +[[nodiscard]] inline QuantityOf auto atan2( + const quantity& y, const quantity& x) noexcept { constexpr auto ref = common_reference(R1, R2); constexpr auto unit = get_unit(ref); diff --git a/test/static/chrono_test.cpp b/test/static/chrono_test.cpp index c4b03cd9..2785041f 100644 --- a/test/static/chrono_test.cpp +++ b/test/static/chrono_test.cpp @@ -63,7 +63,8 @@ static_assert(std::constructible_from>); static_assert(std::constructible_from, std::chrono::hours>); static_assert(std::convertible_to>); -static_assert(!std::constructible_from, std::chrono::seconds>); +static_assert( + !std::constructible_from, std::chrono::seconds>); static_assert(!std::convertible_to>); static_assert( std::constructible_from, sys_seconds>); @@ -76,7 +77,8 @@ static_assert(std::convertible_to, sys_days>); static_assert(!std::constructible_from, sys_days>); static_assert(std::convertible_to>); -static_assert(!std::constructible_from, sys_seconds>); +static_assert( + !std::constructible_from, sys_seconds>); static_assert(!std::convertible_to>); // construction - different rep type (integral to a floating-point) diff --git a/test/static/custom_rep_test_min_impl.cpp b/test/static/custom_rep_test_min_impl.cpp index ccff6080..2e79c557 100644 --- a/test/static/custom_rep_test_min_impl.cpp +++ b/test/static/custom_rep_test_min_impl.cpp @@ -102,7 +102,8 @@ static_assert(creates_quantity, percent>); static_assert(std::constructible_from>, quantity<(si::metre), min_impl>>); static_assert(std::convertible_to>, quantity<(si::metre), min_impl>>); -static_assert(std::constructible_from>, quantity<(si::metre), min_impl>>); +static_assert( + std::constructible_from>, quantity<(si::metre), min_impl>>); static_assert(std::convertible_to>, quantity<(si::metre), min_impl>>); static_assert(std::constructible_from>, quantity<(si::metre), min_impl>>); @@ -122,8 +123,8 @@ static_assert(std::convertible_to, quantity<(si::m static_assert(std::constructible_from>, quantity<(si::metre), int>>); static_assert(std::convertible_to, quantity<(si::metre), min_impl>>); -static_assert( - !std::constructible_from>, quantity<(si::metre), double>>); // narrowing conversion +static_assert(!std::constructible_from>, + quantity<(si::metre), double>>); // narrowing conversion static_assert(!std::convertible_to, quantity<(si::metre), min_impl>>); // min_impl -> T @@ -136,8 +137,8 @@ static_assert(std::convertible_to>, quant static_assert(std::constructible_from, quantity<(si::metre), min_impl>>); static_assert(std::convertible_to>, quantity<(si::metre), double>>); -static_assert( - !std::constructible_from, quantity<(si::metre), min_impl>>); // narrowing conversion +static_assert(!std::constructible_from, + quantity<(si::metre), min_impl>>); // narrowing conversion static_assert(!std::convertible_to>, quantity<(si::metre), int>>); diff --git a/test/static/quantity_point_test.cpp b/test/static/quantity_point_test.cpp index fafbcb65..941f638b 100644 --- a/test/static/quantity_point_test.cpp +++ b/test/static/quantity_point_test.cpp @@ -236,7 +236,8 @@ static_assert(quantity_point::quantity_spec == kind_of); static_assert(quantity_point::dimension == isq::dim_length); static_assert(quantity_point::unit == si::metre); static_assert(is_of_type::point_origin, zeroth_point_origin_>>); -static_assert(is_of_type::absolute_point_origin, zeroth_point_origin_>>); +static_assert( + is_of_type::absolute_point_origin, zeroth_point_origin_>>); static_assert(quantity_point::reference == isq::height[m]); static_assert(quantity_point::quantity_spec == isq::height); @@ -257,7 +258,8 @@ static_assert(quantity_point::quantity_spec == i static_assert(quantity_point::dimension == isq::dim_length); static_assert(quantity_point::unit == si::metre); static_assert(is_of_type::point_origin, struct mean_sea_level>); -static_assert(is_of_type::absolute_point_origin, struct mean_sea_level>); +static_assert( + is_of_type::absolute_point_origin, struct mean_sea_level>); static_assert(quantity_point::reference == isq::height[m]); static_assert(quantity_point::quantity_spec == isq::height); @@ -288,8 +290,9 @@ static_assert(quantity_point::dimension == isq::dim_thermodynamic_temperature); static_assert(quantity_point::unit == si::kelvin); -static_assert(is_of_type::point_origin, - struct si::absolute_zero>); +static_assert( + is_of_type::point_origin, + struct si::absolute_zero>); static_assert( is_of_type::absolute_point_origin, struct si::absolute_zero>); @@ -303,8 +306,9 @@ static_assert(quantity_point::unit == si::kelvin); static_assert(is_of_type::point_origin, struct si::absolute_zero>); -static_assert(is_of_type::absolute_point_origin, - struct si::absolute_zero>); +static_assert( + is_of_type::absolute_point_origin, + struct si::absolute_zero>); static_assert(quantity_point::reference == si::degree_Celsius); static_assert(quantity_point::quantity_spec == @@ -545,7 +549,8 @@ static_assert(std::convertible_to, quantity_point<(i static_assert( std::constructible_from, quantity_point<(isq::speed[m / s])>>); -static_assert(std::convertible_to, quantity_point<(isq::length[m]) / isq::time[s]>>); +static_assert( + std::convertible_to, quantity_point<(isq::length[m]) / isq::time[s]>>); static_assert(std::constructible_from, quantity_point<(isq::speed[m / s])>>); static_assert(std::convertible_to, quantity_point>); @@ -577,12 +582,14 @@ static_assert(!std::convertible_to, quantity_po // mixed origins static_assert(!std::constructible_from, quantity_point<(si::metre)>>); static_assert(!std::convertible_to, quantity_point<(si::metre), mean_sea_level>>); -static_assert(!std::constructible_from, quantity_point<(isq::height[m])>>); +static_assert( + !std::constructible_from, quantity_point<(isq::height[m])>>); static_assert(!std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); static_assert(!std::constructible_from, quantity_point<(si::metre), mean_sea_level>>); static_assert(!std::convertible_to, quantity_point<(si::metre)>>); -static_assert(!std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert( + !std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); static_assert(!std::convertible_to, quantity_point<(isq::height[m])>>); // same explicit origins @@ -593,26 +600,26 @@ static_assert( static_assert(std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(std::convertible_to, + quantity_point<(isq::height[m]), mean_sea_level>>); static_assert(std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::convertible_to, quantity_point<(isq::height[km]), mean_sea_level>>); +static_assert(std::convertible_to, + quantity_point<(isq::height[km]), mean_sea_level>>); static_assert(std::constructible_from, quantity_point<(isq::height[km]), mean_sea_level>>); -static_assert( - std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(std::convertible_to, + quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(std::constructible_from, + quantity_point<(isq::height[m]), mean_sea_level>>); static_assert( std::convertible_to, quantity_point<(si::metre), mean_sea_level>>); -static_assert( - std::constructible_from, quantity_point<(si::metre), mean_sea_level>>); +static_assert(std::constructible_from, + quantity_point<(si::metre), mean_sea_level>>); static_assert( std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); @@ -623,20 +630,21 @@ static_assert(std::convertible_to, quantity_point<(si::metre), ground_level>>); -static_assert(std::convertible_to, quantity_point<(si::metre), ground_level>>); - static_assert( - std::constructible_from, quantity_point<(isq::height[m]), ground_level>>); + std::convertible_to, quantity_point<(si::metre), ground_level>>); + +static_assert(std::constructible_from, + quantity_point<(isq::height[m]), ground_level>>); static_assert( std::convertible_to, quantity_point<(isq::height[m]), ground_level>>); static_assert(std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::convertible_to, quantity_point<(isq::height[km]), mean_sea_level>>); +static_assert(std::convertible_to, + quantity_point<(isq::height[km]), mean_sea_level>>); -static_assert( - std::constructible_from, quantity_point<(isq::height[km]), ground_level>>); +static_assert(std::constructible_from, + quantity_point<(isq::height[km]), ground_level>>); static_assert( std::convertible_to, quantity_point<(isq::height[m]), ground_level>>); @@ -657,11 +665,13 @@ static_assert( static_assert( std::constructible_from, quantity_point<(si::metre), ground_level>>); -static_assert(std::convertible_to, quantity_point<(si::metre), mean_sea_level>>); +static_assert( + std::convertible_to, quantity_point<(si::metre), mean_sea_level>>); static_assert( std::constructible_from, quantity_point<(si::metre), mean_sea_level>>); -static_assert(std::convertible_to, quantity_point<(si::metre), ground_level>>); +static_assert( + std::convertible_to, quantity_point<(si::metre), ground_level>>); static_assert( std::constructible_from, quantity_point<(si::metre), other_ground_level>>); @@ -684,25 +694,25 @@ static_assert( static_assert(std::constructible_from, quantity_point<(isq::height[m]), zeroth_length>>); -static_assert( - std::convertible_to, quantity_point<(isq::length[m]), zeroth_length>>); +static_assert(std::convertible_to, + quantity_point<(isq::length[m]), zeroth_length>>); // quantity_specs with common_quantity_spec static_assert(!std::constructible_from, quantity_point<(isq::height[m]), zeroth_length>>); -static_assert( - !std::convertible_to, quantity_point<(isq::width[m]), zeroth_length>>); +static_assert(!std::convertible_to, + quantity_point<(isq::width[m]), zeroth_length>>); static_assert(!std::constructible_from, quantity_point<(isq::width[m]), zeroth_length>>); -static_assert( - !std::convertible_to, quantity_point<(isq::height[m]), zeroth_length>>); +static_assert(!std::convertible_to, + quantity_point<(isq::height[m]), zeroth_length>>); // different dimensions -static_assert( - !std::constructible_from, quantity_point<(si::kelvin), (si::ice_point)>>); -static_assert( - !std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(!std::constructible_from, + quantity_point<(si::kelvin), (si::ice_point)>>); +static_assert(!std::convertible_to, + quantity_point<(isq::height[m]), mean_sea_level>>); // non-convertible quantity_specs static_assert(!std::constructible_from, @@ -748,16 +758,16 @@ static_assert(std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(std::convertible_to, + quantity_point<(isq::height[m]), mean_sea_level>>); -static_assert( - std::constructible_from, quantity_point<(isq::height[m]), mean_sea_level>>); +static_assert(std::constructible_from, + quantity_point<(isq::height[m]), mean_sea_level>>); static_assert( std::convertible_to, quantity_point<(si::metre), mean_sea_level>>); -static_assert( - std::constructible_from, quantity_point<(si::metre), mean_sea_level>>); +static_assert(std::constructible_from, + quantity_point<(si::metre), mean_sea_level>>); static_assert( std::convertible_to, quantity_point<(isq::height[m]), mean_sea_level>>); @@ -793,8 +803,8 @@ static_assert( std::convertible_to>>); // incompatible origin -static_assert( - !std::constructible_from>, sys_seconds>); +static_assert(!std::constructible_from>, + sys_seconds>); static_assert( !std::convertible_to>>); #endif @@ -832,9 +842,11 @@ static_assert(quantity_point<(isq::height[m]), mean_sea_level>(tower_peak + 42 * static_assert(quantity_point<(isq::height[m]), ground_level>(mean_sea_level + 84 * m).quantity_from(ground_level) == 42 * m); -static_assert(quantity_point<(isq::height[m]), ground_level>(tower_peak + 42 * m).quantity_from(ground_level) == 84 * m); +static_assert(quantity_point<(isq::height[m]), ground_level>(tower_peak + 42 * m).quantity_from(ground_level) == + 84 * m); -static_assert(quantity_point<(isq::height[m]), tower_peak>(mean_sea_level + 42 * m).quantity_from(tower_peak) == -42 * m); +static_assert(quantity_point<(isq::height[m]), tower_peak>(mean_sea_level + 42 * m).quantity_from(tower_peak) == + -42 * m); static_assert(quantity_point<(isq::height[m]), tower_peak>(ground_level + 84 * m).quantity_from(tower_peak) == 42 * m); static_assert((mean_sea_level + 42 * m).point_for(mean_sea_level).quantity_from(mean_sea_level) == 42 * m); @@ -1642,8 +1654,8 @@ static_assert(is_of_type<(zero_Hz + 5 * isq::frequency[Hz]) - (zero_Hz + 10 / (2 static_assert((quantity_point{10 / (2 * isq::period_duration[s])} + 5 * isq::frequency[Hz]).quantity_from_zero() == 10 * isq::frequency[Hz]); -static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz])) - .quantity_from_zero() == 10 * isq::frequency[Hz]); +static_assert((10 / (2 * isq::period_duration[s]) + (zero_Hz + 5 * isq::frequency[Hz])).quantity_from_zero() == + 10 * isq::frequency[Hz]); static_assert((quantity_point{5 * isq::frequency[Hz]} + 10 / (2 * isq::period_duration[s])).quantity_from_zero() == 10 * isq::frequency[Hz]); static_assert((5 * isq::frequency[Hz] + quantity_point{10 / (2 * isq::period_duration[s])}).quantity_from_zero() == diff --git a/test/static/quantity_test.cpp b/test/static/quantity_test.cpp index 6cd56773..3167b018 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -173,8 +173,9 @@ static_assert(!std::constructible_from, quantity<(isq static_assert(!std::convertible_to, quantity<(isq::length[m])>>); // implicit conversion from another quantity only if non-truncating -static_assert(std::constructible_from, quantity<(isq::length[m]), int>>); // int -> double OK -static_assert(std::convertible_to, quantity<(isq::length[m])>>); // int -> double OK +static_assert( + std::constructible_from, quantity<(isq::length[m]), int>>); // int -> double OK +static_assert(std::convertible_to, quantity<(isq::length[m])>>); // int -> double OK static_assert(!std::constructible_from, quantity<(isq::length[m])>>); // truncating double -> int not allowed @@ -188,7 +189,7 @@ static_assert(std::convertible_to, static_assert(!std::constructible_from, quantity<(isq::length[m]), int>>); // truncating metre -> - // kilometre not allowed + // kilometre not allowed static_assert( !std::convertible_to, quantity<(isq::length[km]), int>>); // truncating metre -> kilometre not allowed @@ -355,8 +356,8 @@ static_assert(quantity{123}.quantity_spec == kind_of); #if MP_UNITS_HOSTED using namespace std::chrono_literals; static_assert(std::is_same_v); -//return type for "s" is not specified. is double for msvc -//static_assert(std::is_same_v); +// return type for "s" is not specified. is double for msvc +// static_assert(std::is_same_v); static_assert(quantity{24h}.unit == si::hour); static_assert(quantity{24h}.quantity_spec == kind_of); #endif @@ -455,7 +456,7 @@ static_assert((std::uint8_t{255}* m %= 257 * m).numerical_value_in(m) != [] { #if !(defined MP_UNITS_COMP_CLANG && MP_UNITS_COMP_CLANG < 18 && defined MP_UNITS_MODULES) // next two lines trigger conversions warnings // (warning disabled in CMake for this file) -static_assert(((22 * m) *= 33.33).numerical_value_in(m) ==733); +static_assert(((22 * m) *= 33.33).numerical_value_in(m) == 733); static_assert(((22 * m) /= 3.33).numerical_value_in(m) == 6); static_assert(((22 * m) *= 33.33 * one).numerical_value_in(m) == 733); static_assert(((22 * m) /= 3.33 * one).numerical_value_in(m) == 6); @@ -850,14 +851,17 @@ static_assert(std::equality_comparable_with, quantity, quantity, int>>); static_assert(std::equality_comparable_with, quantity<(si::metre)>>); static_assert(std::equality_comparable_with, quantity<(si::metre), int>>); -static_assert(std::equality_comparable_with, quantity, int>>); +static_assert( + std::equality_comparable_with, quantity, int>>); static_assert(std::equality_comparable_with, quantity<(si::metre)>>); static_assert(std::equality_comparable_with, quantity<(si::metre), int>>); -static_assert(std::equality_comparable_with, quantity<(si::kilo<(si::metre)>), int>>); -static_assert(std::equality_comparable_with, quantity<(isq::height[(si::metre)])>>); -static_assert(std::equality_comparable_with, quantity<(isq::height[(si::metre)]), int>>); static_assert( - std::equality_comparable_with, quantity<(isq::height[(si::kilo<(si::metre)>)]), int>>); + std::equality_comparable_with, quantity<(si::kilo<(si::metre)>), int>>); +static_assert(std::equality_comparable_with, quantity<(isq::height[(si::metre)])>>); +static_assert( + std::equality_comparable_with, quantity<(isq::height[(si::metre)]), int>>); +static_assert(std::equality_comparable_with, + quantity<(isq::height[(si::kilo<(si::metre)>)]), int>>); template concept no_crossdimensional_equality = requires { @@ -1054,11 +1058,12 @@ static_assert(QuantityOf, isq::position_vector / isq::duration>) static_assert(QuantityOf[m / s]>, isq::position_vector / isq::duration>); static_assert(QuantityOf, isq::position_vector / isq::duration>); -static_assert(QuantityOf); // kind of +static_assert(QuantityOf); // kind of static_assert(QuantityOf[m]), (isq::height)>); // kind of static_assert(!QuantityOf); // different kinds static_assert(!QuantityOf); // different kinds static_assert(QuantityOf); -static_assert(QuantityOf); // derived unnamed quantity +static_assert( + QuantityOf); // derived unnamed quantity } // namespace