diff --git a/.clang-format b/.clang-format index bbffcae15..e60e2541c 100644 --- a/.clang-format +++ b/.clang-format @@ -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 @@ -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 @@ -76,7 +82,8 @@ BraceWrapping: # SplitEmptyFunction: true SplitEmptyRecord: false # SplitEmptyNamespace: true -# BreakAfterAttributes: Never +# BreakAdjacentStringLiterals: true +# BreakAfterAttributes: Leave # BreakAfterJavaFieldAnnotations: false # BreakArrays: true # BreakBeforeBinaryOperators: None @@ -160,6 +167,7 @@ MaxEmptyLinesToKeep: 2 # PenaltyBreakComment: 300 # PenaltyBreakFirstLessLess: 120 # PenaltyBreakOpenParenthesis: 0 +# PenaltyBreakScopeResolution: 500 # PenaltyBreakString: 1000 # PenaltyBreakTemplateDeclaration: 10 # PenaltyExcessCharacter: 1000000 @@ -207,6 +215,7 @@ QualifierAlignment: Left # RequiresExpressionIndentation: OuterScope # SeparateDefinitionBlocks: Leave # ShortNamespaceLines: 1 +# SkipMacroDefinitionBody: false # SortIncludes: CaseSensitive # SortJavaStaticImport: Before SortUsingDeclarations: false @@ -228,6 +237,7 @@ SpaceBeforeParensOptions: # AfterFunctionDeclarationName: false # AfterIfMacros: true # AfterOverloadedOperator: false + # AfterPlacementOperator: true AfterRequiresInClause: true # AfterRequiresInExpression: false # BeforeNonEmptyParentheses: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 38ce49323..43956a87d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/src/core/include/mp-units/framework/compare.h b/src/core/include/mp-units/framework/compare.h index aef69ae8f..c044a1293 100644 --- a/src/core/include/mp-units/framework/compare.h +++ b/src/core/include/mp-units/framework/compare.h @@ -38,9 +38,7 @@ namespace mp_units { template requires requires { - { - T::zero() - } -> std::equality_comparable_with; + { T::zero() } -> std::equality_comparable_with; } [[nodiscard]] constexpr bool is_eq_zero(T v) { @@ -49,9 +47,7 @@ template template requires requires { - { - T::zero() - } -> std::equality_comparable_with; + { T::zero() } -> std::equality_comparable_with; } [[nodiscard]] constexpr bool is_neq_zero(T v) { @@ -60,9 +56,7 @@ template template requires requires { - { - T::zero() - } -> std::three_way_comparable_with; + { T::zero() } -> std::three_way_comparable_with; } [[nodiscard]] constexpr bool is_lt_zero(T v) { @@ -71,9 +65,7 @@ template template requires requires { - { - T::zero() - } -> std::three_way_comparable_with; + { T::zero() } -> std::three_way_comparable_with; } [[nodiscard]] constexpr bool is_gt_zero(T v) { @@ -82,9 +74,7 @@ template template requires requires { - { - T::zero() - } -> std::three_way_comparable_with; + { T::zero() } -> std::three_way_comparable_with; } [[nodiscard]] constexpr bool is_lteq_zero(T v) { @@ -93,9 +83,7 @@ template template requires requires { - { - T::zero() - } -> std::three_way_comparable_with; + { T::zero() } -> std::three_way_comparable_with; } [[nodiscard]] constexpr bool is_gteq_zero(T v) { diff --git a/src/core/include/mp-units/framework/customization_points.h b/src/core/include/mp-units/framework/customization_points.h index 8d7add3f8..16a33a2b8 100644 --- a/src/core/include/mp-units/framework/customization_points.h +++ b/src/core/include/mp-units/framework/customization_points.h @@ -118,9 +118,7 @@ struct quantity_values { static constexpr Rep min() noexcept requires requires { - { - std::numeric_limits::lowest() - } -> std::same_as; + { std::numeric_limits::lowest() } -> std::same_as; } { return std::numeric_limits::lowest(); @@ -128,9 +126,7 @@ struct quantity_values { static constexpr Rep max() noexcept requires requires { - { - std::numeric_limits::max() - } -> std::same_as; + { std::numeric_limits::max() } -> std::same_as; } { return std::numeric_limits::max(); diff --git a/src/core/include/mp-units/framework/dimension_concepts.h b/src/core/include/mp-units/framework/dimension_concepts.h index 1d289867b..90330eb29 100644 --- a/src/core/include/mp-units/framework/dimension_concepts.h +++ b/src/core/include/mp-units/framework/dimension_concepts.h @@ -79,8 +79,7 @@ constexpr bool is_per_of_dims> = (... && (BaseDimension || is_dimension_one::value || IsPowerOfDim)); template -concept DerivedDimensionExpr = - BaseDimension || is_dimension_one::value || IsPowerOfDim || is_per_of_dims; +concept DerivedDimensionExpr = BaseDimension || is_dimension_one::value || IsPowerOfDim || is_per_of_dims; template concept SameDimension = diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 3d1b319f8..03088ba88 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -64,9 +64,7 @@ concept IsFloatingPoint = treat_as_floating_point; template concept ValuePreservingTo = requires(FromRep&& from, ToRep to) { - { - to = std::forward(from) - } -> std::same_as; + { to = std::forward(from) } -> std::same_as; } && (IsFloatingPoint || (!IsFloatingPoint && (integral_conversion_factor(FromUnit, ToUnit)))); template @@ -325,9 +323,7 @@ class quantity { // member unary operators [[nodiscard]] constexpr QuantityOf auto operator+() const requires requires(rep v) { - { - +v - } -> std::common_with; + { +v } -> std::common_with; } { return ::mp_units::quantity{+numerical_value_is_an_implementation_detail_, reference}; @@ -335,9 +331,7 @@ class quantity { [[nodiscard]] constexpr QuantityOf auto operator-() const requires requires(rep v) { - { - -v - } -> std::common_with; + { -v } -> std::common_with; } { return ::mp_units::quantity{-numerical_value_is_an_implementation_detail_, reference}; @@ -346,9 +340,7 @@ class quantity { template Q = std::remove_cvref_t> friend constexpr decltype(auto) operator++(FwdQ&& q) requires requires(rep v) { - { - ++v - } -> std::same_as; + { ++v } -> std::same_as; } { ++q.numerical_value_is_an_implementation_detail_; @@ -357,9 +349,7 @@ class quantity { [[nodiscard]] constexpr QuantityOf auto operator++(int) requires requires(rep v) { - { - v++ - } -> std::common_with; + { v++ } -> std::common_with; } { return ::mp_units::quantity{numerical_value_is_an_implementation_detail_++, reference}; @@ -368,9 +358,7 @@ class quantity { template Q = std::remove_cvref_t> friend constexpr decltype(auto) operator--(FwdQ&& q) requires requires(rep v) { - { - --v - } -> std::same_as; + { --v } -> std::same_as; } { --q.numerical_value_is_an_implementation_detail_; @@ -379,9 +367,7 @@ class quantity { [[nodiscard]] constexpr QuantityOf auto operator--(int) requires requires(rep v) { - { - v-- - } -> std::common_with; + { v-- } -> std::common_with; } { return ::mp_units::quantity{numerical_value_is_an_implementation_detail_--, reference}; @@ -390,9 +376,7 @@ class quantity { // compound assignment operators template Q = std::remove_cvref_t> requires requires(rep a, rep b) { - { - a += b - } -> std::same_as; + { a += b } -> std::same_as; } friend constexpr decltype(auto) operator+=(FwdQ&& lhs, const quantity& rhs) { @@ -402,9 +386,7 @@ class quantity { template Q = std::remove_cvref_t> requires requires(rep a, rep b) { - { - a -= b - } -> std::same_as; + { a -= b } -> std::same_as; } friend constexpr decltype(auto) operator-=(FwdQ&& lhs, const quantity& rhs) { @@ -414,9 +396,7 @@ class quantity { template Q = std::remove_cvref_t> requires(!treat_as_floating_point) && requires(rep a, rep b) { - { - a %= b - } -> std::same_as; + { a %= b } -> std::same_as; } friend constexpr decltype(auto) operator%=(FwdQ&& lhs, const quantity& rhs) @@ -428,9 +408,7 @@ class quantity { template Q = std::remove_cvref_t> requires(!Quantity) && requires(rep a, const Value b) { - { - a *= b - } -> std::same_as; + { a *= b } -> std::same_as; } friend constexpr decltype(auto) operator*=(FwdQ&& lhs, const Value& v) { @@ -442,9 +420,7 @@ class quantity { template Q2, std::derived_from Q1 = std::remove_cvref_t> requires(Q2::unit == ::mp_units::one) && requires(rep a, const typename Q2::rep b) { - { - a *= b - } -> std::same_as; + { a *= b } -> std::same_as; } friend constexpr decltype(auto) operator*=(FwdQ1&& lhs, const Q2& rhs) { @@ -457,9 +433,7 @@ class quantity { template Q = std::remove_cvref_t> requires(!Quantity) && requires(rep a, const Value b) { - { - a /= b - } -> std::same_as; + { a /= b } -> std::same_as; } friend constexpr decltype(auto) operator/=(FwdQ&& lhs, const Value& v) { @@ -472,9 +446,7 @@ class quantity { template Q2, std::derived_from Q1 = std::remove_cvref_t> requires(Q2::unit == ::mp_units::one) && requires(rep a, const typename Q2::rep b) { - { - a /= b - } -> std::same_as; + { a /= b } -> std::same_as; } friend constexpr decltype(auto) operator/=(FwdQ1&& lhs, const Q2& rhs) { @@ -673,9 +645,7 @@ MP_UNITS_EXPORT_END template 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; } struct std::common_type { diff --git a/src/core/include/mp-units/framework/quantity_concepts.h b/src/core/include/mp-units/framework/quantity_concepts.h index cfdb705a2..2cdf9eb76 100644 --- a/src/core/include/mp-units/framework/quantity_concepts.h +++ b/src/core/include/mp-units/framework/quantity_concepts.h @@ -78,12 +78,8 @@ concept QuantityLike = requires { requires RepresentationOf::rep, get_quantity_spec(quantity_like_traits::reference).character>; } && requires(T q, typename quantity_like_traits::rep v) { - { - quantity_like_traits::to_numerical_value(q) - } -> detail::ConversionSpecOf::rep>; - { - quantity_like_traits::from_numerical_value(v) - } -> detail::ConversionSpecOf; + { quantity_like_traits::to_numerical_value(q) } -> detail::ConversionSpecOf::rep>; + { quantity_like_traits::from_numerical_value(v) } -> detail::ConversionSpecOf; }; MP_UNITS_EXPORT_END diff --git a/src/core/include/mp-units/framework/quantity_point_concepts.h b/src/core/include/mp-units/framework/quantity_point_concepts.h index 2269f7ec3..89f49dbf6 100644 --- a/src/core/include/mp-units/framework/quantity_point_concepts.h +++ b/src/core/include/mp-units/framework/quantity_point_concepts.h @@ -161,9 +161,7 @@ concept QuantityPointLike = requires { { quantity_point_like_traits::to_numerical_value(qp) } -> detail::ConversionSpecOf::rep>; - { - quantity_point_like_traits::from_numerical_value(v) - } -> detail::ConversionSpecOf; + { quantity_point_like_traits::from_numerical_value(v) } -> detail::ConversionSpecOf; }; } // namespace mp_units diff --git a/src/core/include/mp-units/framework/quantity_spec.h b/src/core/include/mp-units/framework/quantity_spec.h index ef21e47ec..7672ba029 100644 --- a/src/core/include/mp-units/framework/quantity_spec.h +++ b/src/core/include/mp-units/framework/quantity_spec.h @@ -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() < detail::type_name())> {}; + detail::type_name() < detail::type_name())>{}; template using type_list_of_ingredients_less = expr_less; diff --git a/src/core/include/mp-units/framework/quantity_spec_concepts.h b/src/core/include/mp-units/framework/quantity_spec_concepts.h index d72634949..545b1875c 100644 --- a/src/core/include/mp-units/framework/quantity_spec_concepts.h +++ b/src/core/include/mp-units/framework/quantity_spec_concepts.h @@ -86,8 +86,8 @@ template struct is_dimensionless : std::false_type {}; template -concept IsPowerOfQuantitySpec = is_specialization_of_power && (NamedQuantitySpec || - is_dimensionless::value); +concept IsPowerOfQuantitySpec = is_specialization_of_power && + (NamedQuantitySpec || is_dimensionless::value); template @@ -142,8 +142,8 @@ concept ChildQuantitySpecOf = (is_child_of(Child, Parent)); template concept NestedQuantityKindSpecOf = - QuantitySpec && QuantitySpec && - (!SameQuantitySpec)&&ChildQuantitySpecOf; + QuantitySpec && QuantitySpec && (!SameQuantitySpec) && + ChildQuantitySpecOf; template concept QuantitySpecConvertibleTo = diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index ea19739df..e926a1e22 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -271,12 +271,8 @@ constexpr auto operator/(R, Q&& q) = delete; [[nodiscard]] consteval AssociatedUnit auto common_reference(AssociatedUnit auto u1, AssociatedUnit auto u2, AssociatedUnit auto... rest) requires requires { - { - common_quantity_spec(get_quantity_spec(u1), get_quantity_spec(u2), get_quantity_spec(rest)...) - } -> QuantitySpec; - { - common_unit(u1, u2, rest...) - } -> AssociatedUnit; + { common_quantity_spec(get_quantity_spec(u1), get_quantity_spec(u2), get_quantity_spec(rest)...) } -> QuantitySpec; + { common_unit(u1, u2, rest...) } -> AssociatedUnit; } { return common_unit(u1, u2, rest...); @@ -285,12 +281,8 @@ constexpr auto operator/(R, Q&& q) = delete; template [[nodiscard]] consteval Reference auto common_reference(R1 r1, R2 r2, Rest... rest) requires(!(AssociatedUnit && AssociatedUnit && (... && AssociatedUnit))) && requires { - { - common_quantity_spec(get_quantity_spec(r1), get_quantity_spec(r2), get_quantity_spec(rest)...) - } -> QuantitySpec; - { - common_unit(get_unit(r1), get_unit(r2), get_unit(rest)...) - } -> Unit; + { common_quantity_spec(get_quantity_spec(r1), get_quantity_spec(r2), get_quantity_spec(rest)...) } -> QuantitySpec; + { common_unit(get_unit(r1), get_unit(r2), get_unit(rest)...) } -> Unit; } { return detail::reference_t && std::equality_comparable; MP_UNITS_EXPORT template concept Representation = - (is_scalar || is_vector || is_tensor)&&detail::WeaklyRegular && detail::Scalable; + (is_scalar || is_vector || is_tensor) && detail::WeaklyRegular && detail::Scalable; MP_UNITS_EXPORT template concept RepresentationOf = Representation && ((Ch == quantity_character::scalar && is_scalar) || diff --git a/src/core/include/mp-units/framework/unit_concepts.h b/src/core/include/mp-units/framework/unit_concepts.h index e92445427..92a2199bd 100644 --- a/src/core/include/mp-units/framework/unit_concepts.h +++ b/src/core/include/mp-units/framework/unit_concepts.h @@ -161,7 +161,7 @@ concept UnitConvertibleTo = MP_UNITS_EXPORT template concept UnitCompatibleWith = Unit && Unit && QuantitySpec && - (!AssociatedUnit || UnitOf)&&detail::UnitConvertibleTo; + (!AssociatedUnit || UnitOf) && detail::UnitConvertibleTo; template concept OffsetUnit = Unit && requires { T::point_origin; };