mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-02 20:04:27 +02:00
style: clang-format-16 applied to all the code base
This commit is contained in:
@@ -217,8 +217,7 @@ struct point_origin;
|
|||||||
* Satisfied by types derived from an specialization of @c point_origin.
|
* Satisfied by types derived from an specialization of @c point_origin.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept PointOrigin = is_derived_from_specialization_of<T, point_origin> &&
|
concept PointOrigin = is_derived_from_specialization_of<T, point_origin> && requires {
|
||||||
requires {
|
|
||||||
typename T::dimension;
|
typename T::dimension;
|
||||||
requires Dimension<typename T::dimension>;
|
requires Dimension<typename T::dimension>;
|
||||||
typename T::point_origin;
|
typename T::point_origin;
|
||||||
@@ -389,8 +388,8 @@ concept QuantityPointLike = detail::is_quantity_point_like<T>;
|
|||||||
|
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
concept common_type_with_ = // exposition only
|
concept common_type_with_ = // exposition only
|
||||||
(std::same_as<std::common_type_t<T, U>, std::common_type_t<U, T>>) &&
|
(std::same_as<std::common_type_t<T, U>, std::common_type_t<U, T>>)&&(
|
||||||
(std::constructible_from<std::common_type_t<T, U>, T>) && (std::constructible_from<std::common_type_t<T, U>, U>);
|
std::constructible_from<std::common_type_t<T, U>, T>)&&(std::constructible_from<std::common_type_t<T, U>, U>);
|
||||||
|
|
||||||
template<typename T, typename U = T>
|
template<typename T, typename U = T>
|
||||||
concept scalable_number_ = // exposition only
|
concept scalable_number_ = // exposition only
|
||||||
@@ -443,8 +442,7 @@ concept wrapped_quantity_ = // exposition only
|
|||||||
* Satisfied by types that satisfy `(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
* Satisfied by types that satisfy `(!Quantity<T>) && (!WrappedQuantity<T>) && std::regular<T>`.
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
concept Representation = (!Quantity<T>) && (!QuantityLike<T>) &&
|
concept Representation = (!Quantity<T>)&&(!QuantityLike<T>)&&(!wrapped_quantity_<T>)&&std::regular<T> && scalable_<T>;
|
||||||
(!wrapped_quantity_<T>) && std::regular<T> && scalable_<T>;
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
|
@@ -313,11 +313,9 @@ struct pairwise_all {
|
|||||||
}(sizeof...(Ts));
|
}(sizeof...(Ts));
|
||||||
|
|
||||||
// Compare zero or more pairs of neighbours as needed.
|
// Compare zero or more pairs of neighbours as needed.
|
||||||
return [this]<std::size_t... Is>(std::tuple<Ts...> && t, std::index_sequence<Is...>)
|
return [this]<std::size_t... Is>(std::tuple<Ts...>&& t, std::index_sequence<Is...>) {
|
||||||
{
|
|
||||||
return (predicate(std::get<Is>(t), std::get<Is + 1>(t)) && ...);
|
return (predicate(std::get<Is>(t), std::get<Is + 1>(t)) && ...);
|
||||||
}
|
}(std::make_tuple(std::forward<Ts>(ts)...), std::make_index_sequence<num_comparisons>());
|
||||||
(std::make_tuple(std::forward<Ts>(ts)...), std::make_index_sequence<num_comparisons>());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -308,8 +308,7 @@ template<Quantity To, std::same_as<typename To::dimension> D, typename U, std::s
|
|||||||
*/
|
*/
|
||||||
template<Quantity Q1, Quantity Q2>
|
template<Quantity Q1, Quantity Q2>
|
||||||
[[nodiscard]] inline std::common_type_t<Q1, Q2> hypot(const Q1& x, const Q2& y) noexcept
|
[[nodiscard]] inline std::common_type_t<Q1, Q2> hypot(const Q1& x, const Q2& y) noexcept
|
||||||
requires requires { typename std::common_type_t<Q1, Q2>; } &&
|
requires requires { typename std::common_type_t<Q1, Q2>; } && requires(std::common_type_t<Q1, Q2> q) {
|
||||||
requires(std::common_type_t<Q1, Q2> q) {
|
|
||||||
requires requires { hypot(q.number(), q.number()); } || requires { std::hypot(q.number(), q.number()); };
|
requires requires { hypot(q.number(), q.number()); } || requires { std::hypot(q.number(), q.number()); };
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@@ -326,8 +325,7 @@ template<Quantity Q1, Quantity Q2>
|
|||||||
*/
|
*/
|
||||||
template<Quantity Q1, Quantity Q2, Quantity Q3>
|
template<Quantity Q1, Quantity Q2, Quantity Q3>
|
||||||
[[nodiscard]] inline std::common_type_t<Q1, Q2, Q3> hypot(const Q1& x, const Q2& y, const Q3& z) noexcept
|
[[nodiscard]] inline std::common_type_t<Q1, Q2, Q3> hypot(const Q1& x, const Q2& y, const Q3& z) noexcept
|
||||||
requires requires { typename std::common_type_t<Q1, Q2, Q3>; } &&
|
requires requires { typename std::common_type_t<Q1, Q2, Q3>; } && requires(std::common_type_t<Q1, Q2, Q3> q) {
|
||||||
requires(std::common_type_t<Q1, Q2, Q3> q) {
|
|
||||||
requires requires { hypot(q.number(), q.number(), q.number()); } ||
|
requires requires { hypot(q.number(), q.number(), q.number()); } ||
|
||||||
requires { std::hypot(q.number(), q.number(), q.number()); };
|
requires { std::hypot(q.number(), q.number(), q.number()); };
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,8 @@ inline constexpr auto make_quantity = [](auto&& v) {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
concept quantity_one =
|
concept quantity_one =
|
||||||
Quantity<T> &&
|
Quantity<T> &&
|
||||||
(std::same_as<typename T::dimension, dim_one> || std::same_as<typename T::dimension, unknown_dimension<>>) &&
|
(std::same_as<typename T::dimension, dim_one> || std::same_as<typename T::dimension, unknown_dimension<>>)&&detail::
|
||||||
detail::equivalent_unit<typename T::unit, typename T::dimension, ::units::one, typename T::dimension>::value;
|
equivalent_unit<typename T::unit, typename T::dimension, ::units::one, typename T::dimension>::value;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
@@ -31,8 +31,8 @@ struct AlmostEqualsMatcher : Catch::Matchers::MatcherGenericBase {
|
|||||||
AlmostEqualsMatcher(const T& target) : target_{target} {}
|
AlmostEqualsMatcher(const T& target) : target_{target} {}
|
||||||
|
|
||||||
template<QuantityEquivalentTo<T> U>
|
template<QuantityEquivalentTo<T> U>
|
||||||
requires std::same_as<typename T::rep, typename U::rep> && treat_as_floating_point<typename T::rep> bool
|
requires std::same_as<typename T::rep, typename U::rep> && treat_as_floating_point<typename T::rep>
|
||||||
match(const U& other) const
|
bool match(const U& other) const
|
||||||
{
|
{
|
||||||
using std::abs;
|
using std::abs;
|
||||||
using common = std::common_type_t<T, U>;
|
using common = std::common_type_t<T, U>;
|
||||||
|
@@ -110,8 +110,7 @@ static_assert(sizeof(width<metre, double>) == sizeof(double));
|
|||||||
static_assert(sizeof(height<metre, short>) == sizeof(short));
|
static_assert(sizeof(height<metre, short>) == sizeof(short));
|
||||||
|
|
||||||
template<typename Width>
|
template<typename Width>
|
||||||
concept invalid_types =
|
concept invalid_types = requires {
|
||||||
requires {
|
|
||||||
requires !requires { typename quantity_kind<Width, second, int>; }; // unit of a different dimension
|
requires !requires { typename quantity_kind<Width, second, int>; }; // unit of a different dimension
|
||||||
requires !requires { typename quantity_kind<Width, metre, length<metre>>; }; // quantity used as Rep
|
requires !requires { typename quantity_kind<Width, metre, length<metre>>; }; // quantity used as Rep
|
||||||
requires !requires { // quantity point used as Rep
|
requires !requires { // quantity point used as Rep
|
||||||
@@ -444,8 +443,7 @@ concept invalid_compound_assignments_ = requires(quantity_kind<K, U, int> w, Qx
|
|||||||
requires !requires { w %= q; };
|
requires !requires { w %= q; };
|
||||||
};
|
};
|
||||||
template<typename Width>
|
template<typename Width>
|
||||||
concept invalid_compound_assignments =
|
concept invalid_compound_assignments = requires(quantity_kind<Width, metre, int> w, height<metre, int> h) {
|
||||||
requires(quantity_kind<Width, metre, int> w, height<metre, int> h) {
|
|
||||||
requires !requires { w += 1; };
|
requires !requires { w += 1; };
|
||||||
requires !requires { w -= 1; };
|
requires !requires { w -= 1; };
|
||||||
requires !requires { w *= 1 * (km / m); };
|
requires !requires { w *= 1 * (km / m); };
|
||||||
@@ -807,8 +805,7 @@ static_assert(same(quantity_kind_cast<length<centimetre, int>>(width<metre, doub
|
|||||||
static_assert(same(quantity_kind_cast<length<centimetre, int>>(width<cgs::centimetre, int>(1 * cgs_cm)), width<cgs::centimetre, int>(1 * cgs_cm)));
|
static_assert(same(quantity_kind_cast<length<centimetre, int>>(width<cgs::centimetre, int>(1 * cgs_cm)), width<cgs::centimetre, int>(1 * cgs_cm)));
|
||||||
// clang-format on
|
// clang-format on
|
||||||
template<typename Width>
|
template<typename Width>
|
||||||
concept invalid_cast =
|
concept invalid_cast = requires {
|
||||||
requires {
|
|
||||||
requires !requires { quantity_kind_cast<apples<one, int>>(quantity_kind<Width, metre, int>(1 * m)); };
|
requires !requires { quantity_kind_cast<apples<one, int>>(quantity_kind<Width, metre, int>(1 * m)); };
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_kind_cast<horizontal_area<square_metre, int>>(quantity_kind<Width, metre, int>(1 * m));
|
quantity_kind_cast<horizontal_area<square_metre, int>>(quantity_kind<Width, metre, int>(1 * m));
|
||||||
@@ -830,12 +827,10 @@ concept invalid_cast =
|
|||||||
requires !requires { quantity_kind_cast<square_metre>(quantity_kind<Width, metre, int>(1 * m)); };
|
requires !requires { quantity_kind_cast<square_metre>(quantity_kind<Width, metre, int>(1 * m)); };
|
||||||
requires !requires { quantity_kind_cast<second>(quantity_kind<Width, metre, int>(1 * m)); };
|
requires !requires { quantity_kind_cast<second>(quantity_kind<Width, metre, int>(1 * m)); };
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, int>>(
|
quantity_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, int>>(quantity_kind<Width, metre, int>(1 * m));
|
||||||
quantity_kind<Width, metre, int>(1 * m));
|
|
||||||
};
|
};
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_kind_cast<quantity_point<dynamic_origin<dim_one>, one, int>>(
|
quantity_kind_cast<quantity_point<dynamic_origin<dim_one>, one, int>>(quantity_kind<Width, metre, int>(1 * m));
|
||||||
quantity_kind<Width, metre, int>(1 * m));
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
static_assert(invalid_cast<width_kind>);
|
static_assert(invalid_cast<width_kind>);
|
||||||
|
@@ -150,8 +150,7 @@ static_assert(sizeof(abscissa<metre, double>) == sizeof(double));
|
|||||||
static_assert(sizeof(ordinate<metre, short>) == sizeof(short));
|
static_assert(sizeof(ordinate<metre, short>) == sizeof(short));
|
||||||
|
|
||||||
template<typename Width, typename Abscissa>
|
template<typename Width, typename Abscissa>
|
||||||
concept invalid_types =
|
concept invalid_types = requires {
|
||||||
requires {
|
|
||||||
requires !requires { typename quantity_point_kind<Width, metre, int>; }; // width_kind is not a point kind
|
requires !requires { typename quantity_point_kind<Width, metre, int>; }; // width_kind is not a point kind
|
||||||
requires !requires { typename quantity_point_kind<Abscissa, second, int>; }; // unit of a different dimension
|
requires !requires { typename quantity_point_kind<Abscissa, second, int>; }; // unit of a different dimension
|
||||||
requires !requires { typename quantity_point_kind<Abscissa, metre, length<metre>>; }; // quantity used as Rep
|
requires !requires { typename quantity_point_kind<Abscissa, metre, length<metre>>; }; // quantity used as Rep
|
||||||
@@ -478,8 +477,7 @@ concept invalid_compound_assignments_ = requires(quantity_point_kind<PK, U, int>
|
|||||||
requires !requires { x -= q; };
|
requires !requires { x -= q; };
|
||||||
};
|
};
|
||||||
template<typename Abscissa>
|
template<typename Abscissa>
|
||||||
concept invalid_compound_assignments =
|
concept invalid_compound_assignments = requires(quantity_point_kind<Abscissa, metre, int> x) {
|
||||||
requires(quantity_point_kind<Abscissa, metre, int> x) {
|
|
||||||
requires !requires { x += 1; };
|
requires !requires { x += 1; };
|
||||||
requires !requires { x -= 1; };
|
requires !requires { x -= 1; };
|
||||||
requires invalid_compound_assignments_<Abscissa, metre, length<metre, int>>;
|
requires invalid_compound_assignments_<Abscissa, metre, length<metre, int>>;
|
||||||
@@ -599,8 +597,7 @@ static_assert(std::three_way_comparable_with<abscissa<cgs::centimetre, int>, abs
|
|||||||
static_assert(std::three_way_comparable_with<abscissa<metre>, abscissa<cgs::centimetre>>);
|
static_assert(std::three_way_comparable_with<abscissa<metre>, abscissa<cgs::centimetre>>);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
template<typename Int>
|
template<typename Int>
|
||||||
concept invalid_relational =
|
concept invalid_relational = requires(quantity_point_kind<abscissa_kind, metre, Int> x, Int i) {
|
||||||
requires(quantity_point_kind<abscissa_kind, metre, Int> x, Int i) {
|
|
||||||
requires !requires { x < 1; };
|
requires !requires { x < 1; };
|
||||||
requires !requires { x <= 1.0; };
|
requires !requires { x <= 1.0; };
|
||||||
requires !requires { x >= 1 * m; };
|
requires !requires { x >= 1 * m; };
|
||||||
@@ -672,8 +669,7 @@ static_assert(comp(quantity_point_kind_cast<length<centimetre, int>>(abscissa<cg
|
|||||||
static_assert(same(quantity_point_kind_cast<screen_si_cgs_width<metre, int>>(screen_si_width<metre, int>(1 * m)), screen_si_cgs_width<metre, int>(1 * m)));
|
static_assert(same(quantity_point_kind_cast<screen_si_cgs_width<metre, int>>(screen_si_width<metre, int>(1 * m)), screen_si_cgs_width<metre, int>(1 * m)));
|
||||||
// clang-format on
|
// clang-format on
|
||||||
template<typename Int>
|
template<typename Int>
|
||||||
concept invalid_cast =
|
concept invalid_cast = requires(Int i) {
|
||||||
requires(Int i) {
|
|
||||||
requires !requires { quantity_point_kind_cast<apples<one, Int>>(abscissa<metre, Int>(i * m)); };
|
requires !requires { quantity_point_kind_cast<apples<one, Int>>(abscissa<metre, Int>(i * m)); };
|
||||||
requires !requires { quantity_point_kind_cast<rate_of_climb<metre_per_second, Int>>(abscissa<metre, Int>(i * m)); };
|
requires !requires { quantity_point_kind_cast<rate_of_climb<metre_per_second, Int>>(abscissa<metre, Int>(i * m)); };
|
||||||
requires !requires { quantity_point_kind_cast<apple>(abscissa<metre, Int>(i * m)); };
|
requires !requires { quantity_point_kind_cast<apple>(abscissa<metre, Int>(i * m)); };
|
||||||
@@ -689,12 +685,10 @@ concept invalid_cast =
|
|||||||
requires !requires { quantity_point_kind_cast<square_metre>(abscissa<metre, Int>(i * m)); };
|
requires !requires { quantity_point_kind_cast<square_metre>(abscissa<metre, Int>(i * m)); };
|
||||||
requires !requires { quantity_point_kind_cast<second>(abscissa<metre, Int>(i * m)); };
|
requires !requires { quantity_point_kind_cast<second>(abscissa<metre, Int>(i * m)); };
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, Int>>(
|
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, Int>>(abscissa<metre, Int>(i * m));
|
||||||
abscissa<metre, Int>(i * m));
|
|
||||||
};
|
};
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_one>, one, Int>>(
|
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_one>, one, Int>>(abscissa<metre, Int>(i * m));
|
||||||
abscissa<metre, Int>(i * m));
|
|
||||||
};
|
};
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, Int>>(
|
quantity_point_kind_cast<quantity_point<dynamic_origin<dim_length>, metre, Int>>(
|
||||||
|
@@ -46,16 +46,14 @@ struct sea_level_origin : point_origin<dim_length> {};
|
|||||||
// class invariants
|
// class invariants
|
||||||
|
|
||||||
template<typename DimLength>
|
template<typename DimLength>
|
||||||
concept invalid_types =
|
concept invalid_types = requires {
|
||||||
requires {
|
|
||||||
// unit of a different dimension:
|
// unit of a different dimension:
|
||||||
requires !requires { typename quantity_point<dynamic_origin<DimLength>, second, int>; };
|
requires !requires { typename quantity_point<dynamic_origin<DimLength>, second, int>; };
|
||||||
// quantity used as Rep:
|
// quantity used as Rep:
|
||||||
requires !requires { typename quantity_point<dynamic_origin<DimLength>, metre, quantity<DimLength, metre, int>>; };
|
requires !requires { typename quantity_point<dynamic_origin<DimLength>, metre, quantity<DimLength, metre, int>>; };
|
||||||
// quantity point used as Rep:
|
// quantity point used as Rep:
|
||||||
requires !requires {
|
requires !requires {
|
||||||
typename quantity_point<dynamic_origin<DimLength>, metre,
|
typename quantity_point<dynamic_origin<DimLength>, metre, quantity_point<dynamic_origin<DimLength>, metre, int>>;
|
||||||
quantity_point<dynamic_origin<DimLength>, metre, int>>;
|
|
||||||
};
|
};
|
||||||
// reordered arguments:
|
// reordered arguments:
|
||||||
requires !requires { typename quantity_point<metre, dynamic_origin<DimLength>, double>; };
|
requires !requires { typename quantity_point<metre, dynamic_origin<DimLength>, double>; };
|
||||||
@@ -295,8 +293,7 @@ static_assert(
|
|||||||
quantity_point_cast<dim_speed, kilometre_per_hour>(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2);
|
quantity_point_cast<dim_speed, kilometre_per_hour>(quantity_point(2000.0_q_m / 3600.0_q_s)).relative().number() == 2);
|
||||||
|
|
||||||
template<typename Int>
|
template<typename Int>
|
||||||
concept invalid_cast =
|
concept invalid_cast = requires(Int i) {
|
||||||
requires(Int i) {
|
|
||||||
requires !requires {
|
requires !requires {
|
||||||
quantity_point_cast<quantity_point<dynamic_origin<dim_time>, second, Int>>(quantity_point(i * m));
|
quantity_point_cast<quantity_point<dynamic_origin<dim_time>, second, Int>>(quantity_point(i * m));
|
||||||
};
|
};
|
||||||
|
@@ -408,8 +408,7 @@ static_assert((22_q_m /= quantity(3.33)).number() == 6);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename Metre, typename Kilometre>
|
template<typename Metre, typename Kilometre>
|
||||||
concept invalid_compound_assignments =
|
concept invalid_compound_assignments = requires() {
|
||||||
requires() {
|
|
||||||
// truncating not allowed
|
// truncating not allowed
|
||||||
requires !requires(length<Metre, int> l) { l += 2.5_q_m; };
|
requires !requires(length<Metre, int> l) { l += 2.5_q_m; };
|
||||||
requires !requires(length<Metre, int> l) { l -= 2.5_q_m; };
|
requires !requires(length<Metre, int> l) { l -= 2.5_q_m; };
|
||||||
|
Reference in New Issue
Block a user