Skip to content

Commit

Permalink
style: pre-commit updated to clang-format-18.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mpusz committed Sep 18, 2024
1 parent 831c017 commit 089ce3f
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 101 deletions.
12 changes: 11 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,28 @@ AccessModifierOffset: -2
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# AlignFunctionPointers: false
# PadOperators: true
# AlignConsecutiveBitFields:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# AlignFunctionPointers: false
# PadOperators: false
# AlignConsecutiveDeclarations:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# AlignFunctionPointers: false
# PadOperators: false
# AlignConsecutiveMacros:
# Enabled: false
# AcrossEmptyLines: false
# AcrossComments: false
# AlignCompound: false
# AlignFunctionPointers: false
# PadOperators: false
# AlignConsecutiveShortCaseStatements:
# Enabled: false
Expand All @@ -41,8 +45,10 @@ AccessModifierOffset: -2
# OverEmptyLines: 0
# AllowAllArgumentsOnNextLine: true
# AllowAllParametersOfDeclarationOnNextLine: true
# AllowBreakBeforeNoexceptSpecifier: Never
# AllowShortBlocksOnASingleLine: Never
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortCompoundRequirementOnASingleLine: true
# AllowShortEnumsOnASingleLine: true
# AllowShortFunctionsOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: WithoutElse
Expand Down Expand Up @@ -76,7 +82,8 @@ BraceWrapping:
# SplitEmptyFunction: true
SplitEmptyRecord: false
# SplitEmptyNamespace: true
# BreakAfterAttributes: Never
# BreakAdjacentStringLiterals: true
# BreakAfterAttributes: Leave
# BreakAfterJavaFieldAnnotations: false
# BreakArrays: true
# BreakBeforeBinaryOperators: None
Expand Down Expand Up @@ -160,6 +167,7 @@ MaxEmptyLinesToKeep: 2
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakOpenParenthesis: 0
# PenaltyBreakScopeResolution: 500
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
Expand Down Expand Up @@ -207,6 +215,7 @@ QualifierAlignment: Left
# RequiresExpressionIndentation: OuterScope
# SeparateDefinitionBlocks: Leave
# ShortNamespaceLines: 1
# SkipMacroDefinitionBody: false
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
SortUsingDeclarations: false
Expand All @@ -228,6 +237,7 @@ SpaceBeforeParensOptions:
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# AfterPlacementOperator: true
AfterRequiresInClause: true
# AfterRequiresInExpression: false
# BeforeNonEmptyParentheses: false
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.5
rev: v18.1.8
hooks:
- id: clang-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
Expand Down
24 changes: 6 additions & 18 deletions src/core/include/mp-units/framework/compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ namespace mp_units {

template<typename T>
requires requires {
{
T::zero()
} -> std::equality_comparable_with<T>;
{ T::zero() } -> std::equality_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_eq_zero(T v)
{
Expand All @@ -49,9 +47,7 @@ template<typename T>

template<typename T>
requires requires {
{
T::zero()
} -> std::equality_comparable_with<T>;
{ T::zero() } -> std::equality_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_neq_zero(T v)
{
Expand All @@ -60,9 +56,7 @@ template<typename T>

template<typename T>
requires requires {
{
T::zero()
} -> std::three_way_comparable_with<T>;
{ T::zero() } -> std::three_way_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_lt_zero(T v)
{
Expand All @@ -71,9 +65,7 @@ template<typename T>

template<typename T>
requires requires {
{
T::zero()
} -> std::three_way_comparable_with<T>;
{ T::zero() } -> std::three_way_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_gt_zero(T v)
{
Expand All @@ -82,9 +74,7 @@ template<typename T>

template<typename T>
requires requires {
{
T::zero()
} -> std::three_way_comparable_with<T>;
{ T::zero() } -> std::three_way_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_lteq_zero(T v)
{
Expand All @@ -93,9 +83,7 @@ template<typename T>

template<typename T>
requires requires {
{
T::zero()
} -> std::three_way_comparable_with<T>;
{ T::zero() } -> std::three_way_comparable_with<T>;
}
[[nodiscard]] constexpr bool is_gteq_zero(T v)
{
Expand Down
8 changes: 2 additions & 6 deletions src/core/include/mp-units/framework/customization_points.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,15 @@ struct quantity_values {

static constexpr Rep min() noexcept
requires requires {
{
std::numeric_limits<Rep>::lowest()
} -> std::same_as<Rep>;
{ std::numeric_limits<Rep>::lowest() } -> std::same_as<Rep>;
}
{
return std::numeric_limits<Rep>::lowest();
}

static constexpr Rep max() noexcept
requires requires {
{
std::numeric_limits<Rep>::max()
} -> std::same_as<Rep>;
{ std::numeric_limits<Rep>::max() } -> std::same_as<Rep>;
}
{
return std::numeric_limits<Rep>::max();
Expand Down
3 changes: 1 addition & 2 deletions src/core/include/mp-units/framework/dimension_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ constexpr bool is_per_of_dims<per<Ts...>> =
(... && (BaseDimension<Ts> || is_dimension_one<Ts>::value || IsPowerOfDim<Ts>));

template<typename T>
concept DerivedDimensionExpr =
BaseDimension<T> || is_dimension_one<T>::value || IsPowerOfDim<T> || is_per_of_dims<T>;
concept DerivedDimensionExpr = BaseDimension<T> || is_dimension_one<T>::value || IsPowerOfDim<T> || is_per_of_dims<T>;

template<auto D1, auto D2>
concept SameDimension =
Expand Down
60 changes: 15 additions & 45 deletions src/core/include/mp-units/framework/quantity.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ concept IsFloatingPoint = treat_as_floating_point<T>;

template<typename FromRep, typename ToRep, auto FromUnit = one, auto ToUnit = one>
concept ValuePreservingTo = requires(FromRep&& from, ToRep to) {
{
to = std::forward<FromRep>(from)
} -> std::same_as<ToRep&>;
{ to = std::forward<FromRep>(from) } -> std::same_as<ToRep&>;
} && (IsFloatingPoint<ToRep> || (!IsFloatingPoint<FromRep> && (integral_conversion_factor(FromUnit, ToUnit))));

template<typename QFrom, typename QTo>
Expand Down Expand Up @@ -325,19 +323,15 @@ class quantity {
// member unary operators
[[nodiscard]] constexpr QuantityOf<quantity_spec> auto operator+() const
requires requires(rep v) {
{
+v
} -> std::common_with<rep>;
{ +v } -> std::common_with<rep>;
}
{
return ::mp_units::quantity{+numerical_value_is_an_implementation_detail_, reference};
}

[[nodiscard]] constexpr QuantityOf<quantity_spec> auto operator-() const
requires requires(rep v) {
{
-v
} -> std::common_with<rep>;
{ -v } -> std::common_with<rep>;
}
{
return ::mp_units::quantity{-numerical_value_is_an_implementation_detail_, reference};
Expand All @@ -346,9 +340,7 @@ class quantity {
template<typename FwdQ, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
friend constexpr decltype(auto) operator++(FwdQ&& q)
requires requires(rep v) {
{
++v
} -> std::same_as<rep&>;
{ ++v } -> std::same_as<rep&>;
}
{
++q.numerical_value_is_an_implementation_detail_;
Expand All @@ -357,9 +349,7 @@ class quantity {

[[nodiscard]] constexpr QuantityOf<quantity_spec> auto operator++(int)
requires requires(rep v) {
{
v++
} -> std::common_with<rep>;
{ v++ } -> std::common_with<rep>;
}
{
return ::mp_units::quantity{numerical_value_is_an_implementation_detail_++, reference};
Expand All @@ -368,9 +358,7 @@ class quantity {
template<typename FwdQ, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
friend constexpr decltype(auto) operator--(FwdQ&& q)
requires requires(rep v) {
{
--v
} -> std::same_as<rep&>;
{ --v } -> std::same_as<rep&>;
}
{
--q.numerical_value_is_an_implementation_detail_;
Expand All @@ -379,9 +367,7 @@ class quantity {

[[nodiscard]] constexpr QuantityOf<quantity_spec> auto operator--(int)
requires requires(rep v) {
{
v--
} -> std::common_with<rep>;
{ v-- } -> std::common_with<rep>;
}
{
return ::mp_units::quantity{numerical_value_is_an_implementation_detail_--, reference};
Expand All @@ -390,9 +376,7 @@ class quantity {
// compound assignment operators
template<typename FwdQ, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
requires requires(rep a, rep b) {
{
a += b
} -> std::same_as<rep&>;
{ a += b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator+=(FwdQ&& lhs, const quantity& rhs)
{
Expand All @@ -402,9 +386,7 @@ class quantity {

template<typename FwdQ, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
requires requires(rep a, rep b) {
{
a -= b
} -> std::same_as<rep&>;
{ a -= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator-=(FwdQ&& lhs, const quantity& rhs)
{
Expand All @@ -414,9 +396,7 @@ class quantity {

template<typename FwdQ, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
requires(!treat_as_floating_point<rep>) && requires(rep a, rep b) {
{
a %= b
} -> std::same_as<rep&>;
{ a %= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator%=(FwdQ&& lhs, const quantity& rhs)

Expand All @@ -428,9 +408,7 @@ class quantity {

template<typename FwdQ, typename Value, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
requires(!Quantity<Value>) && requires(rep a, const Value b) {
{
a *= b
} -> std::same_as<rep&>;
{ a *= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator*=(FwdQ&& lhs, const Value& v)
{
Expand All @@ -442,9 +420,7 @@ class quantity {

template<typename FwdQ1, QuantityOf<dimensionless> Q2, std::derived_from<quantity> Q1 = std::remove_cvref_t<FwdQ1>>
requires(Q2::unit == ::mp_units::one) && requires(rep a, const typename Q2::rep b) {
{
a *= b
} -> std::same_as<rep&>;
{ a *= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator*=(FwdQ1&& lhs, const Q2& rhs)
{
Expand All @@ -457,9 +433,7 @@ class quantity {

template<typename FwdQ, typename Value, std::derived_from<quantity> Q = std::remove_cvref_t<FwdQ>>
requires(!Quantity<Value>) && requires(rep a, const Value b) {
{
a /= b
} -> std::same_as<rep&>;
{ a /= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator/=(FwdQ&& lhs, const Value& v)
{
Expand All @@ -472,9 +446,7 @@ class quantity {

template<typename FwdQ1, QuantityOf<dimensionless> Q2, std::derived_from<quantity> Q1 = std::remove_cvref_t<FwdQ1>>
requires(Q2::unit == ::mp_units::one) && requires(rep a, const typename Q2::rep b) {
{
a /= b
} -> std::same_as<rep&>;
{ a /= b } -> std::same_as<rep&>;
}
friend constexpr decltype(auto) operator/=(FwdQ1&& lhs, const Q2& rhs)
{
Expand Down Expand Up @@ -673,9 +645,7 @@ MP_UNITS_EXPORT_END

template<mp_units::Quantity Q1, mp_units::Quantity Q2>
requires requires {
{
mp_units::common_reference(Q1::reference, Q2::reference)
} -> mp_units::Reference;
{ mp_units::common_reference(Q1::reference, Q2::reference) } -> mp_units::Reference;
typename std::common_type_t<typename Q1::rep, typename Q2::rep>;
}
struct std::common_type<Q1, Q2> {
Expand Down
8 changes: 2 additions & 6 deletions src/core/include/mp-units/framework/quantity_concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ concept QuantityLike = requires {
requires RepresentationOf<typename quantity_like_traits<T>::rep,
get_quantity_spec(quantity_like_traits<T>::reference).character>;
} && requires(T q, typename quantity_like_traits<T>::rep v) {
{
quantity_like_traits<T>::to_numerical_value(q)
} -> detail::ConversionSpecOf<typename quantity_like_traits<T>::rep>;
{
quantity_like_traits<T>::from_numerical_value(v)
} -> detail::ConversionSpecOf<T>;
{ quantity_like_traits<T>::to_numerical_value(q) } -> detail::ConversionSpecOf<typename quantity_like_traits<T>::rep>;
{ quantity_like_traits<T>::from_numerical_value(v) } -> detail::ConversionSpecOf<T>;
};

MP_UNITS_EXPORT_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,7 @@ concept QuantityPointLike = requires {
{
quantity_point_like_traits<T>::to_numerical_value(qp)
} -> detail::ConversionSpecOf<typename quantity_point_like_traits<T>::rep>;
{
quantity_point_like_traits<T>::from_numerical_value(v)
} -> detail::ConversionSpecOf<T>;
{ quantity_point_like_traits<T>::from_numerical_value(v) } -> detail::ConversionSpecOf<T>;
};

} // namespace mp_units
2 changes: 1 addition & 1 deletion src/core/include/mp-units/framework/quantity_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ struct ingredients_less :
std::bool_constant<(lhs_compl > rhs_compl) ||
(lhs_compl == rhs_compl && ingredients_dimension_less(Lhs::dimension, Rhs::dimension)) ||
(lhs_compl == rhs_compl && Lhs::dimension == Rhs::dimension &&
detail::type_name<Lhs>() < detail::type_name<Rhs>())> {};
detail::type_name<Lhs>() < detail::type_name<Rhs>())>{};

template<typename T1, typename T2>
using type_list_of_ingredients_less = expr_less<T1, T2, ingredients_less>;
Expand Down
Loading

0 comments on commit 089ce3f

Please sign in to comment.