From 144f6951c09ee721167cc3a37518d20a52c0587f Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 17 Mar 2022 23:59:48 +0100 Subject: [PATCH] style: all files refromatted with clang-format --- .clang-format | 63 +- src/core-fmt/include/units/bits/fmt.h | 8 +- src/core-fmt/include/units/format.h | 13 +- .../units/bits/external/fixed_string_io.h | 3 +- src/core-io/include/units/quantity_io.h | 4 +- src/core/include/units/base_dimension.h | 7 +- .../include/units/bits/base_units_ratio.h | 5 +- src/core/include/units/bits/basic_concepts.h | 134 ++- src/core/include/units/bits/common_type.h | 32 +- src/core/include/units/bits/constexpr_math.h | 198 ++--- .../units/bits/derived_dimension_base.h | 12 +- .../include/units/bits/derived_symbol_text.h | 36 +- src/core/include/units/bits/derived_unit.h | 5 +- src/core/include/units/bits/dim_consolidate.h | 3 +- src/core/include/units/bits/dim_unpack.h | 4 +- src/core/include/units/bits/dimension_op.h | 20 +- src/core/include/units/bits/equivalent.h | 67 +- .../include/units/bits/external/downcasting.h | 34 +- .../units/bits/external/fixed_string.h | 33 +- src/core/include/units/bits/external/hacks.h | 49 +- .../include/units/bits/external/text_tools.h | 36 +- .../include/units/bits/external/type_list.h | 11 +- src/core/include/units/bits/pow.h | 2 +- src/core/include/units/bits/quantity_of.h | 12 +- src/core/include/units/bits/ratio_maths.h | 14 +- src/core/include/units/bits/root.h | 2 +- src/core/include/units/bits/unit_text.h | 86 +- src/core/include/units/chrono.h | 14 +- src/core/include/units/customization_points.h | 50 +- src/core/include/units/derived_dimension.h | 13 +- src/core/include/units/magnitude.h | 171 ++-- src/core/include/units/math.h | 84 +- src/core/include/units/prefix.h | 4 +- src/core/include/units/quantity.h | 224 +++-- src/core/include/units/quantity_cast.h | 104 +-- src/core/include/units/quantity_kind.h | 59 +- src/core/include/units/quantity_point.h | 29 +- src/core/include/units/quantity_point_kind.h | 23 +- src/core/include/units/random.h | 828 ++++++++++-------- src/core/include/units/ratio.h | 26 +- src/core/include/units/reference.h | 55 +- src/core/include/units/symbol_text.h | 70 +- src/core/include/units/unit.h | 10 +- .../units/isq/iec80000/binary_prefixes.h | 10 +- .../units/isq/iec80000/modulation_rate.h | 87 +- .../units/isq/iec80000/storage_capacity.h | 273 ++++-- .../units/isq/iec80000/traffic_intensity.h | 15 +- .../units/isq/iec80000/transfer_rate.h | 89 +- .../include/units/isq/natural/acceleration.h | 9 +- .../include/units/isq/natural/energy.h | 9 +- .../include/units/isq/natural/force.h | 9 +- .../include/units/isq/natural/length.h | 9 +- .../include/units/isq/natural/mass.h | 9 +- .../include/units/isq/natural/momentum.h | 9 +- .../include/units/isq/natural/time.h | 9 +- .../include/units/isq/natural/units.h | 3 +- .../units/isq/dimensions/angular_velocity.h | 4 +- .../units/isq/dimensions/catalytic_activity.h | 2 +- .../units/isq/dimensions/concentration.h | 2 +- .../isq/include/units/isq/dimensions/force.h | 2 +- .../units/isq/dimensions/heat_capacity.h | 2 +- .../include/units/isq/dimensions/luminance.h | 2 +- .../units/isq/dimensions/magnetic_flux.h | 2 +- .../units/isq/dimensions/magnetic_induction.h | 7 +- .../units/isq/dimensions/molar_energy.h | 2 +- .../units/isq/dimensions/permittivity.h | 2 +- .../include/units/isq/dimensions/pressure.h | 2 +- .../include/units/isq/dimensions/resistance.h | 6 +- .../isq/dimensions/thermal_conductivity.h | 6 +- .../isq/include/units/isq/dimensions/torque.h | 2 +- .../include/units/isq/si/cgs/acceleration.h | 15 +- .../si-cgs/include/units/isq/si/cgs/area.h | 15 +- .../si-cgs/include/units/isq/si/cgs/cgs.h | 7 +- .../si-cgs/include/units/isq/si/cgs/energy.h | 15 +- .../si-cgs/include/units/isq/si/cgs/force.h | 15 +- .../si-cgs/include/units/isq/si/cgs/length.h | 15 +- .../si-cgs/include/units/isq/si/cgs/mass.h | 15 +- .../si-cgs/include/units/isq/si/cgs/power.h | 13 +- .../include/units/isq/si/cgs/pressure.h | 15 +- .../si-cgs/include/units/isq/si/cgs/speed.h | 13 +- .../si-cgs/include/units/isq/si/cgs/time.h | 6 +- .../si-fps/include/units/isq/si/fps/length.h | 91 +- .../si-fps/include/units/isq/si/fps/mass.h | 103 ++- .../si-fps/include/units/isq/si/fps/power.h | 33 +- .../si-fps/include/units/isq/si/fps/time.h | 10 +- .../si-fps/include/units/isq/si/fps/volume.h | 24 +- .../si-hep/include/units/isq/si/hep/energy.h | 153 +++- .../si-hep/include/units/isq/si/hep/mass.h | 124 ++- .../include/units/isq/si/hep/momentum.h | 91 +- .../si-iau/include/units/isq/si/iau/length.h | 35 +- .../include/units/isq/si/imperial/length.h | 24 +- .../units/isq/si/international/length.h | 78 +- .../units/isq/si/international/speed.h | 13 +- .../units/isq/si/international/volume.h | 15 +- .../include/units/isq/si/typographic/length.h | 45 +- .../include/units/isq/si/uscs/length.h | 38 +- .../include/units/isq/si/catalytic_activity.h | 209 +++-- .../si/include/units/isq/si/charge_density.h | 34 +- .../si/include/units/isq/si/constants.h | 2 +- .../si/include/units/isq/si/current_density.h | 16 +- .../include/units/isq/si/dynamic_viscosity.h | 18 +- .../si/include/units/isq/si/electric_charge.h | 15 +- .../include/units/isq/si/electric_current.h | 197 ++++- .../units/isq/si/electric_field_strength.h | 16 +- .../si/include/units/isq/si/energy_density.h | 13 +- .../si/include/units/isq/si/frequency.h | 159 +++- .../si/include/units/isq/si/heat_capacity.h | 56 +- .../si/include/units/isq/si/inductance.h | 161 +++- src/systems/si/include/units/isq/si/length.h | 206 ++++- .../si/include/units/isq/si/magnetic_flux.h | 161 +++- .../include/units/isq/si/magnetic_induction.h | 177 +++- src/systems/si/include/units/isq/si/mass.h | 395 +++++++-- .../si/include/units/isq/si/momentum.h | 13 +- .../si/include/units/isq/si/permeability.h | 13 +- .../si/include/units/isq/si/permittivity.h | 13 +- src/systems/si/include/units/isq/si/power.h | 159 +++- .../si/include/units/isq/si/resistance.h | 161 +++- src/systems/si/include/units/isq/si/si.h | 20 +- src/systems/si/include/units/isq/si/speed.h | 22 +- .../si/include/units/isq/si/surface_tension.h | 13 +- .../units/isq/si/thermal_conductivity.h | 22 +- .../units/isq/si/thermodynamic_temperature.h | 15 +- src/systems/si/include/units/isq/si/time.h | 116 ++- src/systems/si/include/units/isq/si/torque.h | 15 +- src/systems/si/include/units/isq/si/volume.h | 384 ++++++-- test/unit_test/runtime/distribution_test.cpp | 344 ++++---- test/unit_test/runtime/fmt_test.cpp | 649 ++++---------- test/unit_test/runtime/fmt_units_test.cpp | 59 +- test/unit_test/runtime/magnitude_test.cpp | 108 +-- test/unit_test/runtime/math_test.cpp | 217 +++-- test/unit_test/static/cgs_test.cpp | 2 +- test/unit_test/static/chrono_test.cpp | 20 +- test/unit_test/static/concepts_test.cpp | 20 +- .../static/custom_rep_test_min_expl.cpp | 136 +-- .../static/custom_rep_test_min_impl.cpp | 95 +- test/unit_test/static/custom_unit_test.cpp | 26 +- test/unit_test/static/dimension_op_test.cpp | 92 +- test/unit_test/static/iec80000_test.cpp | 2 +- test/unit_test/static/math_test.cpp | 10 +- test/unit_test/static/point_origin_test.cpp | 8 +- test/unit_test/static/quantity_kind_test.cpp | 282 +++--- .../static/quantity_point_kind_test.cpp | 230 ++--- test/unit_test/static/test_tools.h | 46 +- 143 files changed, 5845 insertions(+), 3563 deletions(-) diff --git a/.clang-format b/.clang-format index 756b6fdc..ed03b21c 100644 --- a/.clang-format +++ b/.clang-format @@ -1,9 +1,13 @@ +######################################################################################## +# NOTE: At least clang-format-15 is needed to format the code of this project correctly +######################################################################################## --- BasedOnStyle: Google --- Language: Cpp AccessModifierOffset: -2 # AlignAfterOpenBracket: Align +# AlignArrayOfStructures: None # AlignConsecutiveMacros: None # AlignConsecutiveAssignments: None # AlignConsecutiveBitFields: None @@ -12,7 +16,6 @@ AccessModifierOffset: -2 # AlignOperands: Align # AlignTrailingComments: true # AllowAllArgumentsOnNextLine: true -# AllowAllConstructorInitializersOnNextLine: true # AllowAllParametersOfDeclarationOnNextLine: true # AllowShortEnumsOnASingleLine: true # AllowShortBlocksOnASingleLine: Never @@ -49,7 +52,7 @@ BraceWrapping: SplitEmptyRecord: false # SplitEmptyNamespace: true # BreakBeforeBinaryOperators: None -# BreakBeforeConceptDeclarations: true +# BreakBeforeConceptDeclarations: Always BreakBeforeBraces: Custom # BreakBeforeInheritanceComma: false BreakInheritanceList: AfterColon @@ -60,27 +63,28 @@ BreakConstructorInitializers: AfterColon # BreakStringLiterals: true ColumnLimit: 120 CommentPragmas: '^ NOLINT' +# CommentPragmas: '^ IWYU pragma:' +QualifierAlignment: Left # CompactNamespaces: false -# ConstructorInitializerAllOnOneLineOrOnePerLine: true # ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 2 # Cpp11BracedListStyle: true DeriveLineEnding: false DerivePointerAlignment: false # DisableFormat: false +# EmptyLineAfterAccessModifier: Never EmptyLineBeforeAccessModifier: Leave # ExperimentalAutoDetectBinPacking: false +# PackConstructorInitializers: NextLine +# ConstructorInitializerAllOnOneLineOrOnePerLine: false +# AllowAllConstructorInitializersOnNextLine: true # FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH - - SECTION - - GIVEN - - WHEN - - THEN -# StatementAttributeLikeMacros: -# - Q_EMIT +# ForEachMacros: +# - foreach +# - Q_FOREACH +# - BOOST_FOREACH +# IfMacros: +# - KJ_IF_MAYBE IncludeBlocks: Merge IncludeCategories: - Regex: '^".*' @@ -95,18 +99,21 @@ IncludeCategories: Priority: 5 # IncludeIsMainRegex: '([-_](test|unittest))?$' # IncludeIsMainSourceRegex: '' +# IndentAccessModifiers: false # IndentCaseLabels: true # IndentCaseBlocks: false # IndentGotoLabels: true # IndentPPDirectives: None # IndentExternBlock: AfterExternBlock -IndentRequires: true +# IndentRequiresClause: true # IndentWidth: 2 # IndentWrappedFunctionNames: false +# InsertBraces: false # InsertTrailingCommas: None # JavaScriptQuotes: Leave # JavaScriptWrapImports: true # KeepEmptyLinesAtTheStartOfBlocks: false +# LambdaBodyIndentation: Signature # MacroBlockBegin: '' # MacroBlockEnd: '' MaxEmptyLinesToKeep: 2 @@ -120,12 +127,14 @@ MaxEmptyLinesToKeep: 2 # PenaltyBreakBeforeFirstCallParameter: 1 # PenaltyBreakComment: 300 # PenaltyBreakFirstLessLess: 120 +# PenaltyBreakOpenParenthesis: 0 # PenaltyBreakString: 1000 # PenaltyBreakTemplateDeclaration: 10 # PenaltyExcessCharacter: 1000000 # PenaltyReturnTypeOnItsOwnLine: 200 # PenaltyIndentedWhitespace: 0 # PointerAlignment: Left +# PPIndentWidth: -1 # RawStringFormats: # - Language: Cpp # Delimiters: @@ -154,10 +163,15 @@ MaxEmptyLinesToKeep: 2 # - ParseTextProtoOrDie # - ParseTestProto # - ParsePartialTestProto -# CanonicalDelimiter: '' +# CanonicalDelimiter: pb # BasedOnStyle: google +# ReferenceAlignment: Pointer # ReflowComments: true -# SortIncludes: true +# RemoveBracesLLVM: false +# RequiresClausePosition: OwnLine +# SeparateDefinitionBlocks: Leave +# ShortNamespaceLines: 1 +# SortIncludes: CaseSensitive # SortJavaStaticImport: Before # SortUsingDeclarations: true # SpaceAfterCStyleCast: false @@ -169,20 +183,35 @@ SpaceAfterTemplateKeyword: false # SpaceBeforeCtorInitializerColon: true # SpaceBeforeInheritanceColon: true # SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: +# AfterControlStatements: true +# AfterForeachMacros: true +# AfterFunctionDefinitionName: false +# AfterFunctionDeclarationName: false +# AfterIfMacros: true +# AfterOverloadedOperator: false + AfterRequiresInClause: true +# AfterRequiresInExpression: false +# BeforeNonEmptyParentheses: false # SpaceAroundPointerQualifiers: Default # SpaceBeforeRangeBasedForLoopColon: true # SpaceInEmptyBlock: false # SpaceInEmptyParentheses: false # SpacesBeforeTrailingComments: 2 -# SpacesInAngles: false +# SpacesInAngles: Never # SpacesInConditionalStatement: false # SpacesInContainerLiterals: true # SpacesInCStyleCastParentheses: false +# SpacesInLineCommentPrefix: +# Minimum: 1 +# Maximum: -1 # SpacesInParentheses: false # SpacesInSquareBrackets: false # SpaceBeforeSquareBrackets: false # BitFieldColonSpacing: Both Standard: Latest +# StatementAttributeLikeMacros: +# - Q_EMIT # StatementMacros: # - Q_UNUSED # - QT_REQUIRE_VERSION diff --git a/src/core-fmt/include/units/bits/fmt.h b/src/core-fmt/include/units/bits/fmt.h index 10bd84d9..21ba73a5 100644 --- a/src/core-fmt/include/units/bits/fmt.h +++ b/src/core-fmt/include/units/bits/fmt.h @@ -86,7 +86,10 @@ template template requires std::is_enum_v -[[nodiscard]] constexpr auto to_ascii(Char value) -> std::underlying_type_t { return value; } +[[nodiscard]] constexpr auto to_ascii(Char value) -> std::underlying_type_t +{ + return value; +} struct width_checker { template @@ -442,7 +445,8 @@ public: constexpr dynamic_specs_handler(dynamic_format_specs& specs, ParseContext& ctx) : specs_setter(specs), specs_(specs), context_(ctx) - {} + { + } template constexpr void on_dynamic_width(T t) diff --git a/src/core-fmt/include/units/format.h b/src/core-fmt/include/units/format.h index 6018d4c3..cd76f23a 100644 --- a/src/core-fmt/include/units/format.h +++ b/src/core-fmt/include/units/format.h @@ -176,7 +176,7 @@ constexpr It parse_units_format(It begin, S end, Handler&& handler) } default: constexpr auto units_types = std::string_view{"Qq"}; - auto const new_end = std::find_first_of(begin, end, units_types.begin(), units_types.end()); + const auto new_end = std::find_first_of(begin, end, units_types.begin(), units_types.end()); if (new_end == end) throw STD_FMT::format_error("invalid format"); if (*new_end == 'Q') { handler.on_quantity_value(begin, new_end); // Edit `on_quantity_value` to add rep modifiers @@ -274,7 +274,8 @@ struct quantity_formatter { explicit quantity_formatter(OutputIt o, quantity q, const quantity_format_specs& fspecs, Locale lc) : out(o), val(std::move(q).number()), specs(fspecs), loc(std::move(lc)) - {} + { + } template S> void on_text(It begin, S end) @@ -357,7 +358,9 @@ private: } template S> - constexpr void on_text(It, S) {} + constexpr void on_text(It, S) + { + } template S> constexpr void on_quantity_value(It begin, S end) @@ -365,7 +368,7 @@ private: if (begin != end) units::detail::parse_units_rep(begin, end, *this, units::treat_as_floating_point); f.quantity_value = true; } - + constexpr void on_quantity_unit(CharT mod) { if (mod != 'q') on_unit_modifier(mod); @@ -427,7 +430,7 @@ public: [[nodiscard]] constexpr auto parse(STD_FMT::basic_format_parse_context& ctx) { auto range = do_parse(ctx); - if(range.first != range.second) + if (range.first != range.second) format_str = std::basic_string_view(&*range.first, static_cast(range.second - range.first)); return range.second; } diff --git a/src/core-io/include/units/bits/external/fixed_string_io.h b/src/core-io/include/units/bits/external/fixed_string_io.h index 59728791..d06cc5cc 100644 --- a/src/core-io/include/units/bits/external/fixed_string_io.h +++ b/src/core-io/include/units/bits/external/fixed_string_io.h @@ -28,7 +28,8 @@ namespace units { template -std::basic_ostream& operator<<(std::basic_ostream& os, const basic_fixed_string& txt) +std::basic_ostream& operator<<(std::basic_ostream& os, + const basic_fixed_string& txt) { return os << txt.c_str(); } diff --git a/src/core-io/include/units/quantity_io.h b/src/core-io/include/units/quantity_io.h index 0f3707b6..b4081ebb 100644 --- a/src/core-io/include/units/quantity_io.h +++ b/src/core-io/include/units/quantity_io.h @@ -45,13 +45,13 @@ void to_stream(std::basic_ostream& os, const quantity& } } -} // namespace detail +} // namespace detail template std::basic_ostream& operator<<(std::basic_ostream& os, const quantity& q) requires requires { os << q.number(); } { - if(os.width()) { + if (os.width()) { // std::setw() applies to the whole quantity output so it has to be first put into std::string std::basic_ostringstream s; s.flags(os.flags()); diff --git a/src/core/include/units/base_dimension.h b/src/core/include/units/base_dimension.h index 41e26b6a..14421e25 100644 --- a/src/core/include/units/base_dimension.h +++ b/src/core/include/units/base_dimension.h @@ -23,8 +23,8 @@ #pragma once // IWYU pragma: begin_exports -#include #include +#include // IWYU pragma: end_exports #include @@ -38,7 +38,7 @@ namespace units { * in the subset can be expressed in terms of the other quantities within that subset. They are referred to as * being mutually independent since a base quantity cannot be expressed as a product of powers of the other base * quantities. - * + * * Base unit is a measurement unit that is adopted by convention for a base quantity in a specific system of units. * * Pair of Symbol and Unit template parameters form an unique identifier of the base dimension. The same identifiers can @@ -61,7 +61,6 @@ struct base_dimension { template struct base_dimension_less : std::bool_constant<(D1::symbol < D2::symbol) || - (D1::symbol == D2::symbol && D1::base_unit::symbol < D1::base_unit::symbol)> { -}; + (D1::symbol == D2::symbol && D1::base_unit::symbol < D1::base_unit::symbol)> {}; } // namespace units diff --git a/src/core/include/units/bits/base_units_ratio.h b/src/core/include/units/bits/base_units_ratio.h index 57b10e2b..c29658c2 100644 --- a/src/core/include/units/bits/base_units_ratio.h +++ b/src/core/include/units/bits/base_units_ratio.h @@ -29,11 +29,12 @@ namespace units::detail { template - requires (E::den == 1 || E::den == 2) // TODO provide support for any den + requires(E::den == 1 || E::den == 2) // TODO provide support for any den constexpr ratio exp_ratio() { const ratio base_ratio = E::dimension::base_unit::ratio; - const ratio positive_ratio = E::num * E::den < 0 ? ratio(base_ratio.den, base_ratio.num, -base_ratio.exp) : base_ratio; + const ratio positive_ratio = + E::num * E::den < 0 ? ratio(base_ratio.den, base_ratio.num, -base_ratio.exp) : base_ratio; const std::intmax_t N = E::num * E::den < 0 ? -E::num : E::num; const ratio ratio_pow = pow(positive_ratio); return E::den == 2 ? sqrt(ratio_pow) : ratio_pow; diff --git a/src/core/include/units/bits/basic_concepts.h b/src/core/include/units/bits/basic_concepts.h index 7b68b994..ecff7a2f 100644 --- a/src/core/include/units/bits/basic_concepts.h +++ b/src/core/include/units/bits/basic_concepts.h @@ -26,9 +26,9 @@ // IWYU pragma: begin_exports #include +#include #include #include -#include // IWYU pragma: end_exports #include @@ -73,7 +73,7 @@ concept Prefix = requires(T* t) { detail::to_prefix_base(t); }; * Satisfied by all ratio values for which `R.num > 0` and `R.den > 0`. */ template -concept UnitRatio = R.num > 0 && R.den > 0; +concept UnitRatio = (R.num > 0) && (R.den > 0); // Unit template @@ -136,10 +136,10 @@ concept Exponent = detail::is_exponent; namespace detail { template - requires (BaseDimension && ...) + requires(BaseDimension && ...) struct derived_dimension_base; -} // namespace detail +} // namespace detail /** * @brief A concept matching all derived dimensions in the library. @@ -170,7 +170,7 @@ auto default_unit() return typename D::coherent_unit{}; } -} // namespace detail +} // namespace detail /** * @brief Returns a 'default' unit of the dimension @@ -200,10 +200,7 @@ using dimension_unit = decltype(detail::default_unit()); * @tparam D Dimension type to use for verification. */ template -concept UnitOf = - Unit && - Dimension && - std::same_as::reference>; +concept UnitOf = Unit && Dimension && std::same_as::reference>; // PointOrigin @@ -217,13 +214,13 @@ struct point_origin; */ template concept PointOrigin = is_derived_from_specialization_of && - requires { - typename T::dimension; - requires Dimension; - typename T::point_origin; - requires std::same_as>; - requires !std::same_as>; - }; + requires { + typename T::dimension; + requires Dimension; + typename T::point_origin; + requires std::same_as>; + requires !std::same_as>; + }; // RebindablePointOriginFor @@ -247,8 +244,7 @@ using rebind_point_origin_dimension = typename conditional concept RebindablePointOriginFor = - requires { typename rebind_point_origin_dimension; } && - PointOrigin> && + requires { typename rebind_point_origin_dimension; } && PointOrigin> && std::same_as::dimension>; // Kind @@ -260,13 +256,11 @@ struct _kind_base; } // namespace detail template typename Base> -concept kind_impl_ = - is_derived_from_specialization_of && - requires { - typename T::base_kind; - typename T::dimension; - requires Dimension; - }; +concept kind_impl_ = is_derived_from_specialization_of && requires { + typename T::base_kind; + typename T::dimension; + requires Dimension; + }; /** * @brief A concept matching all kind types @@ -274,10 +268,8 @@ concept kind_impl_ = * Satisfied by all kind types derived from an specialization of @c kind. */ template -concept Kind = - kind_impl_ && - kind_impl_ && - std::same_as; +concept Kind = kind_impl_ && kind_impl_ && + std::same_as; // PointKind namespace detail { @@ -294,9 +286,7 @@ struct _point_kind_base; */ template concept PointKind = - kind_impl_ && - requires { typename T::origin; } && - PointOrigin && + kind_impl_ && requires { typename T::origin; } && PointOrigin && std::same_as && std::same_as; @@ -394,30 +384,26 @@ concept QuantityPointLike = detail::is_quantity_point_like; // Representation template -concept common_type_with_ = // exposition only - std::same_as, std::common_type_t> && - std::constructible_from, T> && - std::constructible_from, U>; +concept common_type_with_ = // exposition only + (std::same_as, std::common_type_t>) && + (std::constructible_from, T>) && (std::constructible_from, U>); template -concept scalable_number_ = // exposition only - std::regular_invocable, T, U> && - std::regular_invocable, T, U>; +concept scalable_number_ = // exposition only + (std::regular_invocable, T, U>) && (std::regular_invocable, T, U>); template -concept castable_number_ = // exposition only - common_type_with_ && - scalable_number_>; +concept castable_number_ = // exposition only + common_type_with_ && scalable_number_>; template -concept scalable_ = // exposition only - castable_number_ || - (requires { typename T::value_type; } && castable_number_ && scalable_number_>); +concept scalable_ = // exposition only + castable_number_ || (requires { typename T::value_type; } && castable_number_ && + scalable_number_>); template -concept scalable_with_ = // exposition only - common_type_with_ && - scalable_>; +concept scalable_with_ = // exposition only + common_type_with_ && scalable_>; // WrappedQuantity namespace detail { @@ -427,7 +413,9 @@ inline constexpr bool is_wrapped_quantity = false; template requires requires { typename T::value_type; } -inline constexpr bool is_wrapped_quantity = Quantity || QuantityLike || is_wrapped_quantity; +inline constexpr bool is_wrapped_quantity = + Quantity || QuantityLike || + is_wrapped_quantity; template requires requires { typename T::quantity_type; } @@ -442,7 +430,7 @@ inline constexpr bool is_wrapped_quantity = Quantity>`). */ template -concept wrapped_quantity_ = // exposition only +concept wrapped_quantity_ = // exposition only detail::is_wrapped_quantity; /** @@ -451,39 +439,39 @@ concept wrapped_quantity_ = // exposition only * Satisfied by types that satisfy `(!Quantity) && (!WrappedQuantity) && std::regular`. */ template -concept Representation = - (!Quantity) && - (!QuantityLike) && - (!wrapped_quantity_) && - std::regular && - scalable_; +concept Representation = (!Quantity) && (!QuantityLike) && + (!wrapped_quantity_) && std::regular && scalable_; namespace detail { template requires requires(T q) { - typename quantity_like_traits::dimension; - typename quantity_like_traits::unit; - typename quantity_like_traits::rep; - requires Dimension::dimension>; - requires Unit::unit>; - requires Representation::rep>; - { quantity_like_traits::number(q) } -> std::convertible_to::rep>; - } + typename quantity_like_traits::dimension; + typename quantity_like_traits::unit; + typename quantity_like_traits::rep; + requires Dimension::dimension>; + requires Unit::unit>; + requires Representation::rep>; + { + quantity_like_traits::number(q) + } -> std::convertible_to::rep>; + } inline constexpr bool is_quantity_like = true; template requires requires(T q) { - typename quantity_point_like_traits::dimension; - typename quantity_point_like_traits::unit; - typename quantity_point_like_traits::rep; - requires Dimension::dimension>; - requires Unit::unit>; - requires Representation::rep>; - { quantity_point_like_traits::relative(q) } -> QuantityLike; - } + typename quantity_point_like_traits::dimension; + typename quantity_point_like_traits::unit; + typename quantity_point_like_traits::rep; + requires Dimension::dimension>; + requires Unit::unit>; + requires Representation::rep>; + { + quantity_point_like_traits::relative(q) + } -> QuantityLike; + } inline constexpr bool is_quantity_point_like = true; -} // namespace detail +} // namespace detail } // namespace units diff --git a/src/core/include/units/bits/common_type.h b/src/core/include/units/bits/common_type.h index 46940940..5dd8568b 100644 --- a/src/core/include/units/bits/common_type.h +++ b/src/core/include/units/bits/common_type.h @@ -59,7 +59,7 @@ struct common_quantity_reference_impl, reference> { }; template - requires same_unit_reference, dimension_unit>::value + requires(same_unit_reference, dimension_unit>::value) struct common_quantity_reference_impl, reference> { using type = reference>; }; @@ -77,8 +77,8 @@ struct common_quantity_reference_impl, reference> { template Q2> using common_quantity_reference = - TYPENAME detail::common_quantity_reference_impl < - std::remove_const_t, std::remove_const_t>::type; + TYPENAME detail::common_quantity_reference_impl, + std::remove_const_t>::type; } // namespace detail } // namespace units @@ -91,33 +91,37 @@ struct common_type { private: using ref = units::detail::common_quantity_reference; public: - using type = units::quantity>; + using type = + units::quantity>; }; template QP2> requires requires { typename common_type_t; } struct common_type { - using type = units::quantity_point< - units::rebind_point_origin_dimension::dimension>, - typename common_type_t::unit, - typename common_type_t::rep>; + using type = + units::quantity_point::dimension>, + typename common_type_t::unit, + typename common_type_t::rep>; }; template QK2> requires requires { typename common_type_t; } struct common_type { - using type = units::quantity_kind::unit, - typename common_type_t::rep>; + using type = + units::quantity_kind::unit, + typename common_type_t::rep>; }; template QPK2> requires requires { typename common_type_t; } struct common_type { - using type = units::quantity_point_kind::unit, typename common_type_t::rep>; }; -} +} // namespace std diff --git a/src/core/include/units/bits/constexpr_math.h b/src/core/include/units/bits/constexpr_math.h index d57ec497..1a3e719d 100644 --- a/src/core/include/units/bits/constexpr_math.h +++ b/src/core/include/units/bits/constexpr_math.h @@ -76,105 +76,105 @@ struct decimal_fp { // >>> for i in range(1, 100): // ... print(f"/* log({i:>2d}) = */ {math.log(i):.16f},") constexpr std::array log_table{ - /* log( 1) = */ 0.0000000000000000, - /* log( 2) = */ 0.6931471805599453, - /* log( 3) = */ 1.0986122886681098, - /* log( 4) = */ 1.3862943611198906, - /* log( 5) = */ 1.6094379124341003, - /* log( 6) = */ 1.7917594692280550, - /* log( 7) = */ 1.9459101490553132, - /* log( 8) = */ 2.0794415416798357, - /* log( 9) = */ 2.1972245773362196, - /* log(10) = */ 2.3025850929940459, - /* log(11) = */ 2.3978952727983707, - /* log(12) = */ 2.4849066497880004, - /* log(13) = */ 2.5649493574615367, - /* log(14) = */ 2.6390573296152584, - /* log(15) = */ 2.7080502011022101, - /* log(16) = */ 2.7725887222397811, - /* log(17) = */ 2.8332133440562162, - /* log(18) = */ 2.8903717578961645, - /* log(19) = */ 2.9444389791664403, - /* log(20) = */ 2.9957322735539909, - /* log(21) = */ 3.0445224377234230, - /* log(22) = */ 3.0910424533583161, - /* log(23) = */ 3.1354942159291497, - /* log(24) = */ 3.1780538303479458, - /* log(25) = */ 3.2188758248682006, - /* log(26) = */ 3.2580965380214821, - /* log(27) = */ 3.2958368660043291, - /* log(28) = */ 3.3322045101752038, - /* log(29) = */ 3.3672958299864741, - /* log(30) = */ 3.4011973816621555, - /* log(31) = */ 3.4339872044851463, - /* log(32) = */ 3.4657359027997265, - /* log(33) = */ 3.4965075614664802, - /* log(34) = */ 3.5263605246161616, - /* log(35) = */ 3.5553480614894135, - /* log(36) = */ 3.5835189384561099, - /* log(37) = */ 3.6109179126442243, - /* log(38) = */ 3.6375861597263857, - /* log(39) = */ 3.6635616461296463, - /* log(40) = */ 3.6888794541139363, - /* log(41) = */ 3.7135720667043080, - /* log(42) = */ 3.7376696182833684, - /* log(43) = */ 3.7612001156935624, - /* log(44) = */ 3.7841896339182610, - /* log(45) = */ 3.8066624897703196, - /* log(46) = */ 3.8286413964890951, - /* log(47) = */ 3.8501476017100584, - /* log(48) = */ 3.8712010109078911, - /* log(49) = */ 3.8918202981106265, - /* log(50) = */ 3.9120230054281460, - /* log(51) = */ 3.9318256327243257, - /* log(52) = */ 3.9512437185814275, - /* log(53) = */ 3.9702919135521220, - /* log(54) = */ 3.9889840465642745, - /* log(55) = */ 4.0073331852324712, - /* log(56) = */ 4.0253516907351496, - /* log(57) = */ 4.0430512678345503, - /* log(58) = */ 4.0604430105464191, - /* log(59) = */ 4.0775374439057197, - /* log(60) = */ 4.0943445622221004, - /* log(61) = */ 4.1108738641733114, - /* log(62) = */ 4.1271343850450917, - /* log(63) = */ 4.1431347263915326, - /* log(64) = */ 4.1588830833596715, - /* log(65) = */ 4.1743872698956368, - /* log(66) = */ 4.1896547420264252, - /* log(67) = */ 4.2046926193909657, - /* log(68) = */ 4.2195077051761070, - /* log(69) = */ 4.2341065045972597, - /* log(70) = */ 4.2484952420493594, - /* log(71) = */ 4.2626798770413155, - /* log(72) = */ 4.2766661190160553, - /* log(73) = */ 4.2904594411483910, - /* log(74) = */ 4.3040650932041702, - /* log(75) = */ 4.3174881135363101, - /* log(76) = */ 4.3307333402863311, - /* log(77) = */ 4.3438054218536841, - /* log(78) = */ 4.3567088266895917, - /* log(79) = */ 4.3694478524670215, - /* log(80) = */ 4.3820266346738812, - /* log(81) = */ 4.3944491546724391, - /* log(82) = */ 4.4067192472642533, - /* log(83) = */ 4.4188406077965983, - /* log(84) = */ 4.4308167988433134, - /* log(85) = */ 4.4426512564903167, - /* log(86) = */ 4.4543472962535073, - /* log(87) = */ 4.4659081186545837, - /* log(88) = */ 4.4773368144782069, - /* log(89) = */ 4.4886363697321396, - /* log(90) = */ 4.4998096703302650, - /* log(91) = */ 4.5108595065168497, - /* log(92) = */ 4.5217885770490405, - /* log(93) = */ 4.5325994931532563, - /* log(94) = */ 4.5432947822700038, - /* log(95) = */ 4.5538768916005408, - /* log(96) = */ 4.5643481914678361, - /* log(97) = */ 4.5747109785033828, - /* log(98) = */ 4.5849674786705723, - /* log(99) = */ 4.5951198501345898, + /* log( 1) = */ 0.0000000000000000, + /* log( 2) = */ 0.6931471805599453, + /* log( 3) = */ 1.0986122886681098, + /* log( 4) = */ 1.3862943611198906, + /* log( 5) = */ 1.6094379124341003, + /* log( 6) = */ 1.7917594692280550, + /* log( 7) = */ 1.9459101490553132, + /* log( 8) = */ 2.0794415416798357, + /* log( 9) = */ 2.1972245773362196, + /* log(10) = */ 2.3025850929940459, + /* log(11) = */ 2.3978952727983707, + /* log(12) = */ 2.4849066497880004, + /* log(13) = */ 2.5649493574615367, + /* log(14) = */ 2.6390573296152584, + /* log(15) = */ 2.7080502011022101, + /* log(16) = */ 2.7725887222397811, + /* log(17) = */ 2.8332133440562162, + /* log(18) = */ 2.8903717578961645, + /* log(19) = */ 2.9444389791664403, + /* log(20) = */ 2.9957322735539909, + /* log(21) = */ 3.0445224377234230, + /* log(22) = */ 3.0910424533583161, + /* log(23) = */ 3.1354942159291497, + /* log(24) = */ 3.1780538303479458, + /* log(25) = */ 3.2188758248682006, + /* log(26) = */ 3.2580965380214821, + /* log(27) = */ 3.2958368660043291, + /* log(28) = */ 3.3322045101752038, + /* log(29) = */ 3.3672958299864741, + /* log(30) = */ 3.4011973816621555, + /* log(31) = */ 3.4339872044851463, + /* log(32) = */ 3.4657359027997265, + /* log(33) = */ 3.4965075614664802, + /* log(34) = */ 3.5263605246161616, + /* log(35) = */ 3.5553480614894135, + /* log(36) = */ 3.5835189384561099, + /* log(37) = */ 3.6109179126442243, + /* log(38) = */ 3.6375861597263857, + /* log(39) = */ 3.6635616461296463, + /* log(40) = */ 3.6888794541139363, + /* log(41) = */ 3.7135720667043080, + /* log(42) = */ 3.7376696182833684, + /* log(43) = */ 3.7612001156935624, + /* log(44) = */ 3.7841896339182610, + /* log(45) = */ 3.8066624897703196, + /* log(46) = */ 3.8286413964890951, + /* log(47) = */ 3.8501476017100584, + /* log(48) = */ 3.8712010109078911, + /* log(49) = */ 3.8918202981106265, + /* log(50) = */ 3.9120230054281460, + /* log(51) = */ 3.9318256327243257, + /* log(52) = */ 3.9512437185814275, + /* log(53) = */ 3.9702919135521220, + /* log(54) = */ 3.9889840465642745, + /* log(55) = */ 4.0073331852324712, + /* log(56) = */ 4.0253516907351496, + /* log(57) = */ 4.0430512678345503, + /* log(58) = */ 4.0604430105464191, + /* log(59) = */ 4.0775374439057197, + /* log(60) = */ 4.0943445622221004, + /* log(61) = */ 4.1108738641733114, + /* log(62) = */ 4.1271343850450917, + /* log(63) = */ 4.1431347263915326, + /* log(64) = */ 4.1588830833596715, + /* log(65) = */ 4.1743872698956368, + /* log(66) = */ 4.1896547420264252, + /* log(67) = */ 4.2046926193909657, + /* log(68) = */ 4.2195077051761070, + /* log(69) = */ 4.2341065045972597, + /* log(70) = */ 4.2484952420493594, + /* log(71) = */ 4.2626798770413155, + /* log(72) = */ 4.2766661190160553, + /* log(73) = */ 4.2904594411483910, + /* log(74) = */ 4.3040650932041702, + /* log(75) = */ 4.3174881135363101, + /* log(76) = */ 4.3307333402863311, + /* log(77) = */ 4.3438054218536841, + /* log(78) = */ 4.3567088266895917, + /* log(79) = */ 4.3694478524670215, + /* log(80) = */ 4.3820266346738812, + /* log(81) = */ 4.3944491546724391, + /* log(82) = */ 4.4067192472642533, + /* log(83) = */ 4.4188406077965983, + /* log(84) = */ 4.4308167988433134, + /* log(85) = */ 4.4426512564903167, + /* log(86) = */ 4.4543472962535073, + /* log(87) = */ 4.4659081186545837, + /* log(88) = */ 4.4773368144782069, + /* log(89) = */ 4.4886363697321396, + /* log(90) = */ 4.4998096703302650, + /* log(91) = */ 4.5108595065168497, + /* log(92) = */ 4.5217885770490405, + /* log(93) = */ 4.5325994931532563, + /* log(94) = */ 4.5432947822700038, + /* log(95) = */ 4.5538768916005408, + /* log(96) = */ 4.5643481914678361, + /* log(97) = */ 4.5747109785033828, + /* log(98) = */ 4.5849674786705723, + /* log(99) = */ 4.5951198501345898, }; decimal_fp x = to_decimal(v); diff --git a/src/core/include/units/bits/derived_dimension_base.h b/src/core/include/units/bits/derived_dimension_base.h index 4b152718..9284eb0e 100644 --- a/src/core/include/units/bits/derived_dimension_base.h +++ b/src/core/include/units/bits/derived_dimension_base.h @@ -34,17 +34,17 @@ namespace units::detail { * Expression of the dependence of a quantity on the base quantities (and their base dimensions) of a system of * quantities as a product of powers of factors corresponding to the base quantities, omitting any numerical factors. * A power of a factor is the factor raised to an exponent. - * - * A derived dimension can be formed from multiple exponents (i.e. speed is represented as "exponent, exponent"). - * It is also possible to form a derived dimension with only one exponent (i.e. frequency is represented as just + * + * A derived dimension can be formed from multiple exponents (i.e. speed is represented as "exponent, exponent"). It is also possible to form a derived dimension with only one exponent (i.e. frequency is represented as just * "exponent"). - * + * * @note This class template is used by the library engine and should not be directly instantiated by the user. - * + * * @tparam Es zero or more exponents of a derived dimension */ template - requires (BaseDimension && ...) + requires(BaseDimension && ...) struct derived_dimension_base : downcast_base> { using exponents = exponent_list; }; diff --git a/src/core/include/units/bits/derived_symbol_text.h b/src/core/include/units/bits/derived_symbol_text.h index 50ad7d3a..10a08de3 100644 --- a/src/core/include/units/bits/derived_symbol_text.h +++ b/src/core/include/units/bits/derived_symbol_text.h @@ -32,19 +32,16 @@ namespace units::detail { template constexpr auto operator_text() { - if constexpr(Idx == 0) { - if constexpr(Divide && NegativeExpCount == 1) { + if constexpr (Idx == 0) { + if constexpr (Divide && NegativeExpCount == 1) { return basic_fixed_string("1/"); - } - else { + } else { return basic_fixed_string(""); } - } - else { - if constexpr(Divide && NegativeExpCount == 1) { + } else { + if constexpr (Divide && NegativeExpCount == 1) { return basic_fixed_string("/"); - } - else { + } else { return basic_symbol_text(" ⋅ ", " "); } } @@ -54,24 +51,21 @@ template() + Symbol; - if constexpr(E::den != 1) { + const auto txt = operator_text<(E::num < 0), NegativeExpCount, Idx>() + Symbol; + if constexpr (E::den != 1) { // add root part - return txt + basic_fixed_string("^(") + regular() + basic_fixed_string("/") + regular() + basic_fixed_string(")"); - } - else if constexpr(E::num != 1) { + return txt + basic_fixed_string("^(") + regular() + basic_fixed_string("/") + regular() + + basic_fixed_string(")"); + } else if constexpr (E::num != 1) { // add exponent part - if constexpr(NegativeExpCount > 1) { // no '/' sign here (only negative exponents) + if constexpr (NegativeExpCount > 1) { // no '/' sign here (only negative exponents) return txt + superscript(); - } - else if constexpr(E::num != -1) { // -1 is replaced with '/' sign here + } else if constexpr (E::num != -1) { // -1 is replaced with '/' sign here return txt + superscript(); - } - else { + } else { return txt; } - } - else { + } else { return txt; } } diff --git a/src/core/include/units/bits/derived_unit.h b/src/core/include/units/bits/derived_unit.h index 097a08c2..f078c26c 100644 --- a/src/core/include/units/bits/derived_unit.h +++ b/src/core/include/units/bits/derived_unit.h @@ -38,7 +38,7 @@ inline constexpr bool same_scaled_units, Us...> = (UnitOf constexpr ratio inverse_if_negative(const ratio& r) { - if constexpr(E::num * E::den > 0) + if constexpr (E::num * E::den > 0) return r; else return inverse(r); @@ -47,7 +47,8 @@ constexpr ratio inverse_if_negative(const ratio& r) template constexpr ratio derived_ratio(exponent_list) { - return (... * inverse_if_negative(pow(Us::ratio / dimension_unit::ratio))); + return (... * inverse_if_negative( + pow(Us::ratio / dimension_unit::ratio))); } template diff --git a/src/core/include/units/bits/dim_consolidate.h b/src/core/include/units/bits/dim_consolidate.h index 520cc6a6..2590b460 100644 --- a/src/core/include/units/bits/dim_consolidate.h +++ b/src/core/include/units/bits/dim_consolidate.h @@ -54,7 +54,8 @@ struct dim_consolidate> { using type = type_list_push_front>::type, E1>; }; -template +template struct dim_consolidate, exponent, ERest...>> { using r1 = std::ratio; using r2 = std::ratio; diff --git a/src/core/include/units/bits/dim_unpack.h b/src/core/include/units/bits/dim_unpack.h index 614d39c9..ae018f2a 100644 --- a/src/core/include/units/bits/dim_unpack.h +++ b/src/core/include/units/bits/dim_unpack.h @@ -30,8 +30,8 @@ namespace units::detail { /** * @brief Unpacks the list of potentially derived dimensions to a list containing only base dimensions - * - * @tparam Es Exponents of potentially derived dimensions + * + * @tparam Es Exponents of potentially derived dimensions */ template struct dim_unpack; diff --git a/src/core/include/units/bits/dimension_op.h b/src/core/include/units/bits/dimension_op.h index 5b6d16fb..88580625 100644 --- a/src/core/include/units/bits/dimension_op.h +++ b/src/core/include/units/bits/dimension_op.h @@ -34,11 +34,11 @@ namespace units { /** * @brief Unknown dimension - * + * * Sometimes a temporary partial result of a complex calculation may not result in a predefined * dimension. In such a case an `unknown_dimension` is created with a coherent unit of `unknown_coherent_unit` * and ratio(1). - * + * * @tparam Es the list of exponents of ingredient dimensions */ template @@ -70,7 +70,7 @@ struct downcast_dimension_impl { using type = TYPENAME check_unknown>::type; }; -} // namespace detail +} // namespace detail template using downcast_dimension = TYPENAME detail::downcast_dimension_impl::type; @@ -97,8 +97,7 @@ struct dim_invert_impl> { }; template -struct dim_invert_impl : dim_invert_impl> { -}; +struct dim_invert_impl : dim_invert_impl> {}; } // namespace detail @@ -123,7 +122,7 @@ struct to_dimension>> { /** * @brief Merges 2 sorted derived dimensions into one units::derived_dimension_base - * + * * A result of a dimensional calculation may result with many exponents of the same base dimension orginated * from different parts of the equation. As the exponents lists of both operands it is enough to merge them * into one list and consolidate duplicates. Also it is possible that final exponents list will contain only @@ -131,19 +130,22 @@ struct to_dimension>> { * dimension itself. */ template -using merge_dimension = TYPENAME to_dimension>::type>::type; +using merge_dimension = TYPENAME to_dimension>::type>::type; template struct dimension_multiply_impl; template struct dimension_multiply_impl { - using type = downcast_dimension>, derived_dimension_base>>>; + using type = downcast_dimension< + merge_dimension>, derived_dimension_base>>>; }; template struct dimension_multiply_impl { - using type = downcast_dimension>, typename D2::downcast_base_type>>; + using type = + downcast_dimension>, typename D2::downcast_base_type>>; }; template diff --git a/src/core/include/units/bits/equivalent.h b/src/core/include/units/bits/equivalent.h index 5025ecc7..25d399cb 100644 --- a/src/core/include/units/bits/equivalent.h +++ b/src/core/include/units/bits/equivalent.h @@ -30,12 +30,10 @@ namespace units { namespace detail { template -struct equivalent_impl : std::false_type { -}; +struct equivalent_impl : std::false_type {}; template -struct equivalent_impl : std::true_type { -}; +struct equivalent_impl : std::true_type {}; // units @@ -47,39 +45,35 @@ struct equivalent_impl : std::disjunction, std:: // dimensions template -struct equivalent_impl : std::conjunction, - same_unit_reference> { -}; +struct equivalent_impl : + std::conjunction, + same_unit_reference> {}; template -struct equivalent_exp : std::false_type { -}; +struct equivalent_exp : std::false_type {}; template -struct equivalent_exp, exponent> : equivalent_impl { -}; +struct equivalent_exp, exponent> : equivalent_impl {}; template -struct equivalent_derived_dim : std::false_type { -}; +struct equivalent_derived_dim : std::false_type {}; template requires(sizeof...(Es1) == sizeof...(Es2)) struct equivalent_derived_dim, derived_dimension_base> : - std::conjunction...> { -}; + std::conjunction...> {}; template struct equivalent_impl : std::disjunction, std::is_base_of, - equivalent_derived_dim, downcast_base_t>> { -}; + equivalent_derived_dim, downcast_base_t>> {}; // additionally accounts for unknown dimensions template -struct equivalent_unit : std::disjunction, - std::bool_constant::ratio == U2::ratio / dimension_unit::ratio>> {}; +struct equivalent_unit : + std::disjunction, std::bool_constant::ratio == + U2::ratio / dimension_unit::ratio>> {}; // point origins @@ -90,41 +84,46 @@ concept EquivalentPointOrigins = std::same_as>; template -struct equivalent_impl : std::bool_constant< - EquivalentPointOrigins && equivalent_impl::value> {}; +struct equivalent_impl : + std::bool_constant && + equivalent_impl::value> {}; // (point) kinds template struct equivalent_impl : - std::conjunction, - equivalent_impl> {}; + std::conjunction, + equivalent_impl> {}; template struct equivalent_impl : - std::conjunction, - equivalent_impl> {}; + std::conjunction, + equivalent_impl> {}; // quantities, quantity points, quantity (point) kinds template -struct equivalent_impl : std::conjunction, - equivalent_unit> {}; +struct equivalent_impl : + std::conjunction< + equivalent_impl, + equivalent_unit> {}; template -struct equivalent_impl : std::conjunction, - equivalent_impl> {}; +struct equivalent_impl : + std::conjunction, + equivalent_impl> {}; template -struct equivalent_impl : std::conjunction, - equivalent_impl> {}; +struct equivalent_impl : + std::conjunction, + equivalent_impl> {}; template -struct equivalent_impl : std::conjunction, - equivalent_impl> {}; +struct equivalent_impl : + std::conjunction, + equivalent_impl> {}; } // namespace detail diff --git a/src/core/include/units/bits/external/downcasting.h b/src/core/include/units/bits/external/downcasting.h index ef1039e5..96974644 100644 --- a/src/core/include/units/bits/external/downcasting.h +++ b/src/core/include/units/bits/external/downcasting.h @@ -38,17 +38,16 @@ namespace units { template struct downcast_base { using downcast_base_type = BaseType; -UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND + UNITS_DIAGNOSTIC_PUSH + UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND friend auto downcast_guide(downcast_base); friend auto downcast_poison_pill(downcast_base); -UNITS_DIAGNOSTIC_POP + UNITS_DIAGNOSTIC_POP }; template concept Downcastable = - requires { typename T::downcast_base_type; } && - std::derived_from>; + requires { typename T::downcast_base_type; } && std::derived_from>; template concept has_downcast_guide = requires(T t) { downcast_guide(t); }; @@ -58,30 +57,31 @@ concept has_downcast_poison_pill = requires(T t) { downcast_poison_pill(t); }; template struct downcast_child : T { - friend auto downcast_guide(typename T::downcast_base) - { return std::type_identity(); } + friend auto downcast_guide(typename T::downcast_base) { return std::type_identity(); } }; template struct downcast_poison : T { - friend auto downcast_poison_pill(typename T::downcast_base) - { return true; } + friend auto downcast_poison_pill(typename T::downcast_base) { return true; } }; enum class downcast_mode { - off = 0, // no downcasting at all - on = 1, // downcasting always forced -> compile-time errors in case of duplicated definitions - automatic = 2 // downcasting automatically enabled if no collisions are present + off = 0, // no downcasting at all + on = 1, // downcasting always forced -> compile-time errors in case of duplicated definitions + automatic = 2 // downcasting automatically enabled if no collisions are present }; template(UNITS_DOWNCAST_MODE)> -struct downcast_dispatch : std::conditional_t> {}; + downcast_child> { +}; #else - std::conditional_t, - downcast_poison, downcast_child>> {}; + std::conditional_t, downcast_poison, + downcast_child>> { +}; #endif namespace detail { @@ -89,7 +89,7 @@ namespace detail { template constexpr auto downcast_impl() { - if constexpr(has_downcast_guide> && !has_downcast_poison_pill>) + if constexpr (has_downcast_guide> && !has_downcast_poison_pill>) return decltype(downcast_guide(std::declval>()))(); else return std::type_identity(); diff --git a/src/core/include/units/bits/external/fixed_string.h b/src/core/include/units/bits/external/fixed_string.h index 067a9c0c..136b1279 100644 --- a/src/core/include/units/bits/external/fixed_string.h +++ b/src/core/include/units/bits/external/fixed_string.h @@ -22,11 +22,11 @@ #pragma once -#include // IWYU pragma: keep +#include // IWYU pragma: keep // IWYU pragma: begin_exports -#include #include +#include // IWYU pragma: end_exports #include @@ -37,7 +37,7 @@ namespace units { /** * @brief A compile-time fixed string - * + * * @tparam CharT Character type to be used by the string * @tparam N The size of the string */ @@ -70,7 +70,7 @@ struct basic_fixed_string { template [[nodiscard]] constexpr friend basic_fixed_string operator+( - const basic_fixed_string& lhs, const basic_fixed_string& rhs) noexcept + const basic_fixed_string& lhs, const basic_fixed_string& rhs) noexcept { CharT txt[N + N2 + 1] = {}; @@ -82,21 +82,23 @@ struct basic_fixed_string { [[nodiscard]] constexpr bool operator==(const basic_fixed_string& other) const { - if (size() != other.size()) - return false; + if (size() != other.size()) return false; for (size_t i = 0; i != size(); ++i) { - if ((*this)[i] != other[i]) - return false; + if ((*this)[i] != other[i]) return false; } return true; // return std::ranges::equal(*this, other); } template - [[nodiscard]] friend constexpr bool operator==(const basic_fixed_string&, const basic_fixed_string&) { return false; } + [[nodiscard]] friend constexpr bool operator==(const basic_fixed_string&, const basic_fixed_string&) + { + return false; + } template - [[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs, const basic_fixed_string& rhs) + [[nodiscard]] friend constexpr auto operator<=>(const basic_fixed_string& lhs, + const basic_fixed_string& rhs) { auto first1 = lhs.begin(); const auto last1 = lhs.end(); @@ -105,12 +107,11 @@ struct basic_fixed_string { auto comp = std::compare_three_way(); for (; first1 != last1 && first2 != last2; ++first1, ++first2) - if (auto cmp = comp(*first1, *first2); cmp != 0) - return cmp; - - return first1 != last1 ? std::strong_ordering::greater : - first2 != last2 ? std::strong_ordering::less : - std::strong_ordering::equal; + if (auto cmp = comp(*first1, *first2); cmp != 0) return cmp; + + return first1 != last1 ? std::strong_ordering::greater + : first2 != last2 ? std::strong_ordering::less + : std::strong_ordering::equal; // return std::lexicographical_compare_three_way(lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); } }; diff --git a/src/core/include/units/bits/external/hacks.h b/src/core/include/units/bits/external/hacks.h index 3826ae44..5a983540 100644 --- a/src/core/include/units/bits/external/hacks.h +++ b/src/core/include/units/bits/external/hacks.h @@ -39,9 +39,9 @@ #define UNITS_DIAGNOSTIC_PUSH UNITS_PRAGMA(GCC diagnostic push) #define UNITS_DIAGNOSTIC_POP UNITS_PRAGMA(GCC diagnostic pop) #define UNITS_DIAGNOSTIC_IGNORE_PRAGMAS UNITS_PRAGMA(GCC diagnostic ignored "-Wpragmas") -#define UNITS_DIAGNOSTIC_IGNORE(X) \ - UNITS_DIAGNOSTIC_IGNORE_PRAGMAS \ - UNITS_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") \ +#define UNITS_DIAGNOSTIC_IGNORE(X) \ + UNITS_DIAGNOSTIC_IGNORE_PRAGMAS \ + UNITS_PRAGMA(GCC diagnostic ignored "-Wunknown-pragmas") \ UNITS_PRAGMA(GCC diagnostic ignored "-Wunknown-warning-option") \ UNITS_PRAGMA(GCC diagnostic ignored X) #define UNITS_DIAGNOSTIC_IGNORE_EXPR_ALWAYS_TF @@ -87,8 +87,8 @@ #endif -#include #include +#include #if UNITS_COMP_MSVC || UNITS_COMP_CLANG @@ -130,14 +130,14 @@ using concepts::totally_ordered; using ranges::compare_three_way; using ranges::input_iterator; -using ranges::sentinel_for; using ranges::iter_value_t; +using ranges::sentinel_for; namespace ranges { using ::ranges::begin; -using ::ranges::end; using ::ranges::distance; +using ::ranges::end; using ::ranges::input_range; using ::ranges::range_value_t; @@ -145,7 +145,7 @@ using ::ranges::range_value_t; using ::ranges::lower_bound; using ::ranges::transform; -} +} // namespace ranges // missing in Range-v3 template @@ -153,15 +153,10 @@ concept floating_point = std::is_floating_point_v; template concept default_initializable = - std::constructible_from && - requires { T{}; } && - requires { ::new (static_cast(nullptr)) T; }; + std::constructible_from && requires { T{}; } && requires { ::new (static_cast(nullptr)) T; }; template -concept invocable = -requires(F&& f, Args&&... args) { - std::invoke(std::forward(f), std::forward(args)...); -}; +concept invocable = requires(F&& f, Args&&... args) { std::invoke(std::forward(f), std::forward(args)...); }; template concept regular_invocable = invocable; @@ -172,44 +167,44 @@ constexpr bool cmp_equal(T t, U u) noexcept using UT = std::make_unsigned_t; using UU = std::make_unsigned_t; if constexpr (std::is_signed_v == std::is_signed_v) - return t == u; + return t == u; else if constexpr (std::is_signed_v) - return t < 0 ? false : UT(t) == u; + return t < 0 ? false : UT(t) == u; else - return u < 0 ? false : t == UU(u); + return u < 0 ? false : t == UU(u); } - + template constexpr bool cmp_not_equal(T t, U u) noexcept { return !cmp_equal(t, u); } - + template constexpr bool cmp_less(T t, U u) noexcept { using UT = std::make_unsigned_t; using UU = std::make_unsigned_t; if constexpr (std::is_signed_v == std::is_signed_v) - return t < u; + return t < u; else if constexpr (std::is_signed_v) - return t < 0 ? true : UT(t) < u; + return t < 0 ? true : UT(t) < u; else - return u < 0 ? false : t < UU(u); + return u < 0 ? false : t < UU(u); } - + template constexpr bool cmp_greater(T t, U u) noexcept { return cmp_less(u, t); } - + template constexpr bool cmp_less_equal(T t, U u) noexcept { return !cmp_greater(t, u); } - + template constexpr bool cmp_greater_equal(T t, U u) noexcept { @@ -220,7 +215,7 @@ template constexpr bool in_range(T t) noexcept { return std::cmp_greater_equal(t, std::numeric_limits::min()) && - std::cmp_less_equal(t, std::numeric_limits::max()); + std::cmp_less_equal(t, std::numeric_limits::max()); } #elif UNITS_LIBCXX < 14000 @@ -233,4 +228,4 @@ using ::ranges::compare_three_way; #endif -} // namespace std +} // namespace std diff --git a/src/core/include/units/bits/external/text_tools.h b/src/core/include/units/bits/external/text_tools.h index 6d9b321f..a70e5107 100644 --- a/src/core/include/units/bits/external/text_tools.h +++ b/src/core/include/units/bits/external/text_tools.h @@ -28,19 +28,29 @@ namespace units::detail { template - requires (0 <= Value) && (Value < 10) + requires(0 <= Value) && (Value < 10) inline constexpr basic_fixed_string superscript_number = ""; -template<> inline constexpr basic_fixed_string superscript_number<0> = "\u2070"; -template<> inline constexpr basic_fixed_string superscript_number<1> = "\u00b9"; -template<> inline constexpr basic_fixed_string superscript_number<2> = "\u00b2"; -template<> inline constexpr basic_fixed_string superscript_number<3> = "\u00b3"; -template<> inline constexpr basic_fixed_string superscript_number<4> = "\u2074"; -template<> inline constexpr basic_fixed_string superscript_number<5> = "\u2075"; -template<> inline constexpr basic_fixed_string superscript_number<6> = "\u2076"; -template<> inline constexpr basic_fixed_string superscript_number<7> = "\u2077"; -template<> inline constexpr basic_fixed_string superscript_number<8> = "\u2078"; -template<> inline constexpr basic_fixed_string superscript_number<9> = "\u2079"; +template<> +inline constexpr basic_fixed_string superscript_number<0> = "\u2070"; +template<> +inline constexpr basic_fixed_string superscript_number<1> = "\u00b9"; +template<> +inline constexpr basic_fixed_string superscript_number<2> = "\u00b2"; +template<> +inline constexpr basic_fixed_string superscript_number<3> = "\u00b3"; +template<> +inline constexpr basic_fixed_string superscript_number<4> = "\u2074"; +template<> +inline constexpr basic_fixed_string superscript_number<5> = "\u2075"; +template<> +inline constexpr basic_fixed_string superscript_number<6> = "\u2076"; +template<> +inline constexpr basic_fixed_string superscript_number<7> = "\u2077"; +template<> +inline constexpr basic_fixed_string superscript_number<8> = "\u2078"; +template<> +inline constexpr basic_fixed_string superscript_number<9> = "\u2079"; inline constexpr basic_symbol_text superscript_minus("\u207b", "-"); @@ -49,9 +59,9 @@ inline constexpr basic_symbol_text superscript_prefix("", "^"); template constexpr auto superscript_helper() { - if constexpr(Value < 0) + if constexpr (Value < 0) return superscript_minus + superscript_helper<-Value>(); - else if constexpr(Value < 10) + else if constexpr (Value < 10) return basic_symbol_text(superscript_number, basic_fixed_string(static_cast('0' + Value))); else return superscript_helper() + superscript_helper(); diff --git a/src/core/include/units/bits/external/type_list.h b/src/core/include/units/bits/external/type_list.h index 409e08c1..e92e4dec 100644 --- a/src/core/include/units/bits/external/type_list.h +++ b/src/core/include/units/bits/external/type_list.h @@ -111,7 +111,7 @@ struct split_impl { }; template typename List, std::size_t Idx, std::size_t N, typename T, typename... Rest> - requires (Idx < N) + requires(Idx < N) struct split_impl : split_impl { using base = split_impl; using first_list = TYPENAME type_list_push_front_impl::type; @@ -144,8 +144,7 @@ template struct type_list_split_half; template typename List, typename... Types> -struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> { -}; +struct type_list_split_half> : type_list_split, (sizeof...(Types) + 1) / 2> {}; // merge_sorted @@ -174,13 +173,15 @@ template typename List, typename Lhs1, typename... LhsRest template typename Pred> requires Pred::value struct type_list_merge_sorted_impl, List, Pred> { - using type = TYPENAME type_list_push_front_impl, List, Pred>::type, Lhs1>::type; + using type = TYPENAME type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Lhs1>::type; }; template typename List, typename Lhs1, typename... LhsRest, typename Rhs1, typename... RhsRest, template typename Pred> struct type_list_merge_sorted_impl, List, Pred> { - using type = TYPENAME type_list_push_front_impl, List, Pred>::type, Rhs1>::type; + using type = TYPENAME type_list_push_front_impl< + typename type_list_merge_sorted_impl, List, Pred>::type, Rhs1>::type; }; } // namespace detail diff --git a/src/core/include/units/bits/pow.h b/src/core/include/units/bits/pow.h index 28b2ab8f..4e688f01 100644 --- a/src/core/include/units/bits/pow.h +++ b/src/core/include/units/bits/pow.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include namespace units::detail { diff --git a/src/core/include/units/bits/quantity_of.h b/src/core/include/units/bits/quantity_of.h index 4ec1368f..ef7e8d77 100644 --- a/src/core/include/units/bits/quantity_of.h +++ b/src/core/include/units/bits/quantity_of.h @@ -36,12 +36,16 @@ template typename DimTemplate> inline constexpr bool same_exponents_of = false; template typename DimTemplate> -inline constexpr bool same_exponents_of, DimTemplate> = requires { typename DimTemplate, unknown_coherent_unit, typename Es::dimension...>; } && std::same_as, typename DimTemplate, unknown_coherent_unit, typename Es::dimension...>::recipe>; +inline constexpr bool same_exponents_of, DimTemplate> = + requires { typename DimTemplate, unknown_coherent_unit, typename Es::dimension...>; } && + std::same_as, typename DimTemplate, unknown_coherent_unit, + typename Es::dimension...>::recipe>; -} // namespace detail +} // namespace detail template typename DimTemplate> -concept EquivalentUnknownDimensionOfT = Dimension && is_derived_from_specialization_of && detail::same_exponents_of; +concept EquivalentUnknownDimensionOfT = Dimension && is_derived_from_specialization_of && + detail::same_exponents_of; #endif @@ -56,7 +60,7 @@ concept DimensionOfT = Dimension && (is_derived_from_specialization_of #endif -); + ); /** * @brief A concept matching all quantities with provided dimension class template diff --git a/src/core/include/units/bits/ratio_maths.h b/src/core/include/units/bits/ratio_maths.h index c58fe5dd..d9a6494a 100644 --- a/src/core/include/units/bits/ratio_maths.h +++ b/src/core/include/units/bits/ratio_maths.h @@ -22,6 +22,7 @@ #pragma once +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include namespace units::detail { @@ -106,9 +106,9 @@ template // (a 10^e) mod b -> [ (a mod b) (10^e mod b) ] mod b return std::gcd( - b, static_cast(mulmod(static_cast(a % b), - modpow(10, static_cast(e), static_cast(b)), - static_cast(b)))); + b, static_cast(mulmod(static_cast(a % b), + modpow(10, static_cast(e), static_cast(b)), + static_cast(b)))); } constexpr void cwap(std::intmax_t& lhs, std::intmax_t& rhs) @@ -119,8 +119,8 @@ constexpr void cwap(std::intmax_t& lhs, std::intmax_t& rhs) } // Computes the rational gcd of n1/d1 x 10^e1 and n2/d2 x 10^e2 -[[nodiscard]] constexpr auto gcd_frac(std::intmax_t n1, std::intmax_t d1, std::intmax_t e1, std::intmax_t n2, std::intmax_t d2, - std::intmax_t e2) noexcept +[[nodiscard]] constexpr auto gcd_frac(std::intmax_t n1, std::intmax_t d1, std::intmax_t e1, std::intmax_t n2, + std::intmax_t d2, std::intmax_t e2) noexcept { // Short cut for equal ratios if (n1 == n2 && d1 == d2 && e1 == e2) { @@ -153,7 +153,7 @@ constexpr void cwap(std::intmax_t& lhs, std::intmax_t& rhs) constexpr void normalize(std::intmax_t& num, std::intmax_t& den, std::intmax_t& exp) { - if(num == 0) { + if (num == 0) { den = 1; exp = 0; return; diff --git a/src/core/include/units/bits/root.h b/src/core/include/units/bits/root.h index e718ef8a..8e074e16 100644 --- a/src/core/include/units/bits/root.h +++ b/src/core/include/units/bits/root.h @@ -33,7 +33,7 @@ namespace units::detail { template requires gt_zero -[[nodiscard]] constexpr std::intmax_t iroot_impl(std::intmax_t v, F const& pow_function) noexcept +[[nodiscard]] constexpr std::intmax_t iroot_impl(std::intmax_t v, const F& pow_function) noexcept { if constexpr (N == 1) { return v; diff --git a/src/core/include/units/bits/unit_text.h b/src/core/include/units/bits/unit_text.h index 5fc86bed..ec6675bc 100644 --- a/src/core/include/units/bits/unit_text.h +++ b/src/core/include/units/bits/unit_text.h @@ -24,8 +24,8 @@ #include #include -#include #include +#include namespace units::detail { @@ -34,33 +34,25 @@ inline constexpr basic_symbol_text base_multiplier("\u00D7 10", "x 10"); template constexpr auto ratio_text() { - if constexpr(R.num == 1 && R.den == 1 && R.exp != 0) { + if constexpr (R.num == 1 && R.den == 1 && R.exp != 0) { return base_multiplier + superscript(); - } - else if constexpr(R.num != 1 || R.den != 1 || R.exp != 0) { + } else if constexpr (R.num != 1 || R.den != 1 || R.exp != 0) { auto txt = basic_fixed_string("[") + regular(); - if constexpr(R.den == 1) { - if constexpr(R.exp == 0) { + if constexpr (R.den == 1) { + if constexpr (R.exp == 0) { return txt + basic_fixed_string("]"); + } else { + return txt + " " + base_multiplier + superscript() + basic_fixed_string("]"); } - else { - return txt + " " + base_multiplier + superscript() + - basic_fixed_string("]"); + } else { + if constexpr (R.exp == 0) { + return txt + basic_fixed_string("/") + regular() + basic_fixed_string("]"); + } else { + return txt + basic_fixed_string("/") + regular() + " " + base_multiplier + superscript() + + basic_fixed_string("]"); } } - else { - if constexpr(R.exp == 0) { - return txt + basic_fixed_string("/") + regular() + - basic_fixed_string("]"); - } - else { - return txt + basic_fixed_string("/") + regular() + - " " + base_multiplier + superscript() + - basic_fixed_string("]"); - } - } - } - else { + } else { return basic_fixed_string(""); } } @@ -68,32 +60,29 @@ constexpr auto ratio_text() template constexpr auto prefix_or_ratio_text() { - if constexpr(R.num == 1 && R.den == 1 && R.exp == 0) { + if constexpr (R.num == 1 && R.den == 1 && R.exp == 0) { // no ratio/prefix return basic_fixed_string(""); - } - else { + } else { if constexpr (!is_same_v) { // try to form a prefix using prefix = downcast>; - if constexpr(!is_same_v>) { + if constexpr (!is_same_v>) { // print as a prefixed unit return prefix::symbol; - } - else { + } else { // print as a ratio of the coherent unit constexpr auto txt = ratio_text(); - if constexpr(SymbolLen > 0 && txt.standard().size() > 0) + if constexpr (SymbolLen > 0 && txt.standard().size() > 0) return txt + basic_fixed_string(" "); else return txt; } - } - else { + } else { // print as a ratio of the coherent unit constexpr auto txt = ratio_text(); - if constexpr(SymbolLen > 0 && txt.standard().size() > 0) + if constexpr (SymbolLen > 0 && txt.standard().size() > 0) return txt + basic_fixed_string(" "); else return txt; @@ -104,7 +93,8 @@ constexpr auto prefix_or_ratio_text() template constexpr auto derived_dimension_unit_text(exponent_list, std::index_sequence) { - return (exp_text::symbol, negative_exp_count, Idxs>() + ... + basic_symbol_text(basic_fixed_string(""))); + return (exp_text::symbol, negative_exp_count, Idxs>() + ... + + basic_symbol_text(basic_fixed_string(""))); } template @@ -120,10 +110,9 @@ template constexpr auto exponent_list_with_named_units(Exp) { using dim = TYPENAME Exp::dimension; - if constexpr(dimension_unit::is_named) { + if constexpr (dimension_unit::is_named) { return exponent_list(); - } - else { + } else { using recipe = TYPENAME dim::recipe; return exponent_list_with_named_units(recipe()); } @@ -135,10 +124,7 @@ constexpr auto exponent_list_with_named_units(exponent_list) return type_list_join(); } -constexpr auto exponent_list_with_named_units(exponent_list<> empty) -{ - return empty; -} +constexpr auto exponent_list_with_named_units(exponent_list<> empty) { return empty; } template constexpr auto derived_dimension_unit_text() @@ -149,29 +135,31 @@ constexpr auto derived_dimension_unit_text() template // TODO replace with `inline constexpr bool has_symbol` when MSVC cathes up -concept has_symbol = requires{ T::symbol; }; +concept has_symbol = requires { T::symbol; }; template constexpr auto unit_text() { - if constexpr(has_symbol) { + if constexpr (has_symbol) { // already has a symbol so print it return U::symbol; - } - else { + } else { // print as a prefix or ratio of a coherent unit using coherent_unit = dimension_unit; - if constexpr(has_symbol) { + if constexpr (has_symbol) { // use predefined coherent unit symbol constexpr auto symbol_text = coherent_unit::symbol; - constexpr auto prefix_txt = prefix_or_ratio_text(); + constexpr auto prefix_txt = + prefix_or_ratio_text(); return prefix_txt + symbol_text; - } - else { + } else { // use derived dimension ingredients to create a unit symbol constexpr auto symbol_text = derived_dimension_unit_text(); - constexpr auto prefix_txt = prefix_or_ratio_text(); + constexpr auto prefix_txt = + prefix_or_ratio_text(); return prefix_txt + symbol_text; } } diff --git a/src/core/include/units/chrono.h b/src/core/include/units/chrono.h index df29e486..d19660de 100644 --- a/src/core/include/units/chrono.h +++ b/src/core/include/units/chrono.h @@ -40,14 +40,15 @@ struct quantity_like_traits> { }; template -struct clock_origin : point_origin { }; +struct clock_origin : point_origin {}; template struct quantity_point_like_traits>> { using origin = clock_origin; using unit = downcast_unit; using rep = Rep; - [[nodiscard]] static constexpr auto relative(const std::chrono::time_point>& qp) { + [[nodiscard]] static constexpr auto relative(const std::chrono::time_point>& qp) + { return qp.time_since_epoch(); } }; @@ -61,17 +62,16 @@ constexpr std::intmax_t pow_10(std::intmax_t v) { gsl_Expects(v > 0); std::intmax_t res = 1; - for(std::intmax_t i = 0; i < v; i++) - res *= 10; + for (std::intmax_t i = 0; i < v; i++) res *= 10; return res; } template constexpr auto to_std_ratio_impl() { - if constexpr(R.exp == 0) + if constexpr (R.exp == 0) return std::ratio{}; - else if constexpr(R.exp > 0) + else if constexpr (R.exp > 0) return std::ratio{}; else return std::ratio{}; @@ -96,4 +96,4 @@ template return ret_type(to_std_duration(qp.relative())); } -} // namespace units +} // namespace units diff --git a/src/core/include/units/customization_points.h b/src/core/include/units/customization_points.h index 04827e1f..54bd9c35 100644 --- a/src/core/include/units/customization_points.h +++ b/src/core/include/units/customization_points.h @@ -30,11 +30,11 @@ namespace units { /** * @brief Specifies if a value of a type should be treated as a floating-point value - * + * * This type trait should be specialized for a custom representation type to specify * that values fo this type should be treated by the library as a floating-point ones * which will enable implicit conversions between quantities. - * + * * @tparam Rep a representation type for which a type trait is defined */ template @@ -46,40 +46,56 @@ inline constexpr bool treat_as_floating_point = treat_as_floating_point struct quantity_values { static constexpr Rep zero() noexcept requires std::constructible_from - { return Rep(0); } + { + return Rep(0); + } static constexpr Rep one() noexcept requires std::constructible_from - { return Rep(1); } + { + return Rep(1); + } static constexpr Rep min() noexcept - requires requires { { std::numeric_limits::lowest() } -> std::same_as; } - { return std::numeric_limits::lowest(); } + requires requires { + { + std::numeric_limits::lowest() + } -> std::same_as; + } + { + return std::numeric_limits::lowest(); + } static constexpr Rep max() noexcept - requires requires { { std::numeric_limits::max() } -> std::same_as; } - { return std::numeric_limits::max(); } + requires requires { + { + std::numeric_limits::max() + } -> std::same_as; + } + { + return std::numeric_limits::max(); + } }; /** * @brief Provides support for external quantity-like types - * + * * The type trait should provide the following nested type aliases: @c dimension, @c unit, @c rep, * and a static member function @c number(T) that will return the raw value of the quantity. - * + * * Usage example can be found in @c units/chrono.h header file. - * + * * @tparam T the type to provide support for */ template @@ -87,15 +103,15 @@ struct quantity_like_traits; /** * @brief Provides support for external quantity point-like types - * + * * The type trait should provide the following nested type aliases: @c origin, @c unit, @c rep, * and a static member function @c relative(T) that will return the quantity-like value of the quantity point. - * + * * Usage example can be found in @c units/chrono.h header file. - * + * * @tparam T the type to provide support for */ template struct quantity_point_like_traits; -} // namespace units +} // namespace units diff --git a/src/core/include/units/derived_dimension.h b/src/core/include/units/derived_dimension.h index ce014c40..0ea8f23a 100644 --- a/src/core/include/units/derived_dimension.h +++ b/src/core/include/units/derived_dimension.h @@ -40,7 +40,7 @@ namespace detail { /** * @brief Converts user provided derived dimension specification into a valid units::derived_dimension_base definition - * + * * User provided definition of a derived dimension may contain the same base dimension repeated more than once on the * list possibly hidden in other derived units provided by the user. The process here should: * 1. Extract derived dimensions into exponents of base dimensions. @@ -49,23 +49,24 @@ namespace detail { * this base dimension. */ template -using make_dimension = TYPENAME to_derived_dimension_base::type, exponent_less>>::type>::type; +using make_dimension = TYPENAME to_derived_dimension_base< + typename dim_consolidate::type, exponent_less>>::type>::type; } // namespace detail /** * @brief The list of exponents of dimensions (both base and derived) provided by the user - * + * * This is the user's interface to create derived dimensions. Exponents list can contain powers of factors of both * base and derived dimensions. This is called a "recipe" of the dimension and among others is used to print * unnamed coherent units of this dimension. - * + * * Coherent unit is a unit that, for a given system of quantities and for a chosen set of base units, is a product * of powers of base units with no other proportionality factor than one. * * The implementation is responsible for unpacking all of the dimensions into a list containing only base dimensions * and their factors and putting them to derived_dimension_base class template. - * + * * Sometimes units of equivalent quantities in different systems of units do not share the same reference so they * cannot be easily converted to each other. An example can be a pressure for which a coherent unit in SI is pascal * and in CGS barye. Those two units are not directly related with each other with some ratio. As they both are @@ -75,7 +76,7 @@ using make_dimension = TYPENAME to_derived_dimension_base -concept BaseRep = std::is_same_v || std::is_same_v, long double>; +concept BaseRep = std::is_same_v || std::is_same_v < std::remove_cvref_t, +long double > ; /** * @brief A basis vector in our magnitude representation, raised to some rational power. @@ -108,7 +109,7 @@ template inline constexpr bool is_base_power = false; template inline constexpr bool is_base_power> = true; -} // namespace detail +} // namespace detail /** * @brief Concept to detect whether a _type_ is a valid base power. @@ -119,34 +120,40 @@ inline constexpr bool is_base_power> = true; template concept BasePower = detail::is_base_power; -namespace detail +namespace detail { + +constexpr auto inverse(BasePower auto bp) { -constexpr auto inverse(BasePower auto bp) { bp.power.num *= -1; return bp; } // `widen_t` gives the widest arithmetic type in the same category, for intermediate computations. -template requires std::is_arithmetic_v -using widen_t = std::conditional_t< - std::is_floating_point_v, - long double, - std::conditional_t, std::intmax_t, std::uintmax_t>>; +template + requires std::is_arithmetic_v +using widen_t = std::conditional_t, long double, + std::conditional_t, std::intmax_t, std::uintmax_t>>; // Raise an arbitrary arithmetic type to a positive integer power at compile time. -template requires std::is_arithmetic_v -constexpr T int_power(T base, std::integral auto exp){ +template + requires std::is_arithmetic_v +constexpr T int_power(T base, std::integral auto exp) +{ // As this function should only be called at compile time, the exceptions herein function as // "parameter-compatible static_asserts", and should not result in exceptions at runtime. - if (exp < 0) { throw std::invalid_argument{"int_power only supports positive integer powers"}; } + if (exp < 0) { + throw std::invalid_argument{"int_power only supports positive integer powers"}; + } - constexpr auto checked_multiply = [] (auto a, auto b) { + constexpr auto checked_multiply = [](auto a, auto b) { const auto result = a * b; - if (result / a != b) { throw std::overflow_error{"Wraparound detected"}; } + if (result / a != b) { + throw std::overflow_error{"Wraparound detected"}; + } return result; }; - constexpr auto checked_square = [checked_multiply] (auto a) { return checked_multiply(a, a); }; + constexpr auto checked_square = [checked_multiply](auto a) { return checked_multiply(a, a); }; // TODO(chogg): Unify this implementation with the one in pow.h. That one takes its exponent as a // template parameter, rather than a function parameter. @@ -163,7 +170,8 @@ constexpr T int_power(T base, std::integral auto exp){ } -template requires std::is_arithmetic_v +template + requires std::is_arithmetic_v constexpr widen_t compute_base_power(BasePower auto bp) { // This utility can only handle integer powers. To compute rational powers at compile time, we'll @@ -171,8 +179,12 @@ constexpr widen_t compute_base_power(BasePower auto bp) // // Note that since this function should only be called at compile time, the point of these // exceptions is to act as "static_assert substitutes", not to throw actual exceptions at runtime. - if (bp.power.den != 1) { throw std::invalid_argument{"Rational powers not yet supported"}; } - if (bp.power.exp < 0) { throw std::invalid_argument{"Unsupported exp value"}; } + if (bp.power.den != 1) { + throw std::invalid_argument{"Rational powers not yet supported"}; + } + if (bp.power.exp < 0) { + throw std::invalid_argument{"Unsupported exp value"}; + } if (bp.power.num < 0) { if constexpr (std::is_integral_v) { @@ -191,10 +203,10 @@ constexpr widen_t compute_base_power(BasePower auto bp) // The input is the desired result, but in a (wider) intermediate type. The point of this function // is to cast to the desired type, but avoid overflow in doing so. template - requires std::is_arithmetic_v - && std::is_arithmetic_v - && (std::is_integral_v == std::is_integral_v) -constexpr To checked_static_cast(From x) { + requires std::is_arithmetic_v && std::is_arithmetic_v && + (std::is_integral_v == std::is_integral_v) +constexpr To checked_static_cast(From x) +{ // This function should only ever be called at compile time. The purpose of these exceptions is // to produce compiler errors, because we cannot `static_assert` on function arguments. if constexpr (std::is_integral_v) { @@ -209,20 +221,22 @@ constexpr To checked_static_cast(From x) { return static_cast(x); } -} // namespace detail +} // namespace detail /** * @brief Equality detection for two base powers. */ template -constexpr bool operator==(T t, U u) { +constexpr bool operator==(T t, U u) +{ return std::is_same_v && (t.get_base() == u.get_base()) && (t.power == u.power); } /** * @brief A BasePower, raised to a rational power E. */ -constexpr auto pow(BasePower auto bp, ratio p) { +constexpr auto pow(BasePower auto bp, ratio p) +{ bp.power = bp.power * p; return bp; } @@ -233,9 +247,10 @@ namespace detail { // Find the smallest prime factor of `n`. constexpr std::intmax_t find_first_factor(std::intmax_t n) { - for (std::intmax_t f = 2; f * f <= n; f += 1 + (f % 2)) - { - if (n % f == 0) { return f; } + for (std::intmax_t f = 2; f * f <= n; f += 1 + (f % 2)) { + if (n % f == 0) { + return f; + } } return n; } @@ -244,8 +259,7 @@ constexpr std::intmax_t find_first_factor(std::intmax_t n) constexpr std::intmax_t multiplicity(std::intmax_t factor, std::intmax_t n) { std::intmax_t m = 0; - while (n % factor == 0) - { + while (n % factor == 0) { n /= factor; ++m; } @@ -257,18 +271,26 @@ constexpr std::intmax_t multiplicity(std::intmax_t factor, std::intmax_t n) // Undefined unless base > 1, pow >= 0, and (base ^ pow) evenly divides n. constexpr std::intmax_t remove_power(std::intmax_t base, std::intmax_t pow, std::intmax_t n) { - while (pow-- > 0) { n /= base; } + while (pow-- > 0) { + n /= base; + } return n; } // A way to check whether a number is prime at compile time. constexpr bool is_prime(std::intmax_t n) { return (n > 1) && (find_first_factor(n) == n); } -constexpr bool is_valid_base_power(const BasePower auto &bp) { - if (bp.power == 0) { return false; } +constexpr bool is_valid_base_power(const BasePower auto& bp) +{ + if (bp.power == 0) { + return false; + } - if constexpr (std::is_same_v) { return is_prime(bp.get_base()); } - else { return bp.get_base() > 0; } + if constexpr (std::is_same_v) { + return is_prime(bp.get_base()); + } else { + return bp.get_base() > 0; + } } // A function object to apply a predicate to all consecutive pairs of values in a sequence. @@ -277,16 +299,19 @@ struct pairwise_all { Predicate predicate; template - constexpr bool operator()(Ts&&... ts) const { + constexpr bool operator()(Ts&&... ts) const + { // Carefully handle different sizes, avoiding unsigned integer underflow. constexpr auto num_comparisons = [](auto num_elements) { return (num_elements > 1) ? (num_elements - 1) : 0; }(sizeof...(Ts)); // Compare zero or more pairs of neighbours as needed. - return [this](std::tuple &&t, std::index_sequence) { + return [this](std::tuple && t, std::index_sequence) + { return (predicate(std::get(t), std::get(t)) && ...); - }(std::make_tuple(std::forward(ts)...), std::make_index_sequence()); + } + (std::make_tuple(std::forward(ts)...), std::make_index_sequence()); } }; @@ -296,8 +321,9 @@ pairwise_all(T) -> pairwise_all; // Check whether a sequence of (possibly heterogeneously typed) values are strictly increasing. template - requires (std::is_signed_v && ...) -constexpr bool strictly_increasing(Ts&&... ts) { + requires(std::is_signed_v && ...) +constexpr bool strictly_increasing(Ts&&... ts) +{ return pairwise_all{std::less{}}(std::forward(ts)...); } @@ -310,14 +336,13 @@ inline constexpr bool all_bases_in_order = strictly_increasing(BPs.get_base()... template inline constexpr bool is_base_power_pack_valid = all_base_powers_valid && all_bases_in_order; -constexpr bool is_rational(BasePower auto bp) { +constexpr bool is_rational(BasePower auto bp) +{ return std::is_integral_v && (bp.power.den == 1) && (bp.power.exp >= 0); } -constexpr bool is_integral(BasePower auto bp) { - return is_rational(bp) && bp.power.num > 0; -} -} // namespace detail +constexpr bool is_integral(BasePower auto bp) { return is_rational(bp) && bp.power.num > 0; } +} // namespace detail /** * @brief A representation for positive real numbers which optimizes taking products and rational powers. @@ -341,7 +366,7 @@ template inline constexpr bool is_magnitude = false; template inline constexpr bool is_magnitude> = true; -} // namespace detail +} // namespace detail /** * @brief Concept to detect whether T is a valid Magnitude. @@ -354,7 +379,8 @@ concept Magnitude = detail::is_magnitude; */ template requires std::is_floating_point_v || (std::is_integral_v && is_integral(magnitude{})) -constexpr T get_value(const magnitude &) { +constexpr T get_value(const magnitude&) +{ // Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow. constexpr auto result = detail::checked_static_cast((detail::compute_base_power(BPs) * ...)); @@ -372,18 +398,26 @@ struct pi_base { // Magnitude equality implementation. template -constexpr bool operator==(magnitude, magnitude) { - if constexpr (sizeof...(LeftBPs) == sizeof...(RightBPs)) { return ((LeftBPs == RightBPs) && ...); } - else { return false; } +constexpr bool operator==(magnitude, magnitude) +{ + if constexpr (sizeof...(LeftBPs) == sizeof...(RightBPs)) { + return ((LeftBPs == RightBPs) && ...); + } else { + return false; + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Magnitude rational powers implementation. template -constexpr auto pow(magnitude) { - if constexpr (E == 0) { return magnitude<>{}; } - else { return magnitude{}; } +constexpr auto pow(magnitude) +{ + if constexpr (E == 0) { + return magnitude<>{}; + } else { + return magnitude{}; + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -396,9 +430,10 @@ constexpr auto operator*(Magnitude auto m, magnitude<>) { return m; } // Recursive case for the product of any two non-identity Magnitudes. template -constexpr auto operator*(magnitude, magnitude) { +constexpr auto operator*(magnitude, magnitude) +{ // Case for when H1 has the smaller base. - if constexpr(H1.get_base() < H2.get_base()){ + if constexpr (H1.get_base() < H2.get_base()) { if constexpr (sizeof...(T1) == 0) { // Shortcut for the "pure prepend" case, which makes it easier to implement some of the other cases. return magnitude{}; @@ -408,7 +443,7 @@ constexpr auto operator*(magnitude, magnitude) { } // Case for when H2 has the smaller base. - if constexpr(H1.get_base() > H2.get_base()){ + if constexpr (H1.get_base() > H2.get_base()) { return magnitude

{} * (magnitude{} * magnitude{}); } @@ -441,23 +476,25 @@ constexpr auto operator/(Magnitude auto l, Magnitude auto r) { return l * pow<-1 namespace detail { // Helper to perform prime factorization at compile time. template - requires (N > 0) + requires(N > 0) struct prime_factorization { static constexpr std::intmax_t first_base = find_first_factor(N); static constexpr std::intmax_t first_power = multiplicity(first_base, N); static constexpr std::intmax_t remainder = remove_power(first_base, first_power, N); - static constexpr auto value = magnitude{} - * prime_factorization::value; + static constexpr auto value = + magnitude{} * prime_factorization::value; }; // Specialization for the prime factorization of 1 (base case). template<> -struct prime_factorization<1> { static constexpr magnitude<> value{}; }; +struct prime_factorization<1> { + static constexpr magnitude<> value{}; +}; template inline constexpr auto prime_factorization_v = prime_factorization::value; -} // namespace detail +} // namespace detail /** * @brief Convert any positive integer to a Magnitude. @@ -466,11 +503,11 @@ inline constexpr auto prime_factorization_v = prime_factorization::value; * manually adding base powers. */ template - requires (R.num > 0) -constexpr Magnitude auto as_magnitude() { - return pow(detail::prime_factorization_v<10>) - * detail::prime_factorization_v - / detail::prime_factorization_v; + requires(R.num > 0) +constexpr Magnitude auto as_magnitude() +{ + return pow(detail::prime_factorization_v<10>) * detail::prime_factorization_v / + detail::prime_factorization_v; } -} // namespace units +} // namespace units diff --git a/src/core/include/units/math.h b/src/core/include/units/math.h index d07bcb25..d2c2728e 100644 --- a/src/core/include/units/math.h +++ b/src/core/include/units/math.h @@ -60,7 +60,7 @@ template using unit = downcast_unit(Q::unit::ratio)>; using std::pow; return quantity( - static_cast(pow(q.number(), static_cast(Num) / static_cast(Den)))); + static_cast(pow(q.number(), static_cast(Num) / static_cast(Den)))); } } @@ -74,7 +74,7 @@ template */ template [[nodiscard]] inline Quantity auto sqrt(const Q& q) noexcept - requires requires { sqrt(q.number()); } || requires { std::sqrt(q.number()); } + requires requires { sqrt(q.number()); } || requires { std::sqrt(q.number()); } { using dim = dimension_pow; using unit = downcast_unit; @@ -126,7 +126,7 @@ template */ template [[nodiscard]] inline quantity abs(const quantity& q) noexcept - requires requires { abs(q.number()); } || requires { std::abs(q.number()); } + requires requires { abs(q.number()); } || requires { std::abs(q.number()); } { using std::abs; return quantity(abs(q.number())); @@ -155,13 +155,12 @@ template */ template [[nodiscard]] constexpr quantity floor(const quantity& q) noexcept - requires ((!treat_as_floating_point) || - requires { floor(q.number()); } || - requires { std::floor(q.number()); }) && - (std::same_as || requires { - ::units::quantity_cast(q); - quantity::one(); - }) + requires((!treat_as_floating_point) || requires { floor(q.number()); } || + requires { std::floor(q.number()); }) && + (std::same_as || requires { + ::units::quantity_cast(q); + quantity::one(); + }) { const auto handle_signed_results = [&](const T& res) { if (res > q) { @@ -169,20 +168,17 @@ template } return res; }; - if constexpr(treat_as_floating_point) { + if constexpr (treat_as_floating_point) { using std::floor; - if constexpr(std::is_same_v) { + if constexpr (std::is_same_v) { return quantity(floor(q.number())); - } - else { + } else { return handle_signed_results(quantity(floor(quantity_cast(q).number()))); } - } - else { - if constexpr(std::is_same_v) { + } else { + if constexpr (std::is_same_v) { return q; - } - else { + } else { return handle_signed_results(quantity_cast(q)); } } @@ -209,13 +205,11 @@ template D, typename U, std::s */ template [[nodiscard]] constexpr quantity ceil(const quantity& q) noexcept - requires ((!treat_as_floating_point) || - requires { ceil(q.number()); } || - requires { std::ceil(q.number()); }) && - (std::same_as || requires { - ::units::quantity_cast(q); - quantity::one(); - }) + requires((!treat_as_floating_point) || requires { ceil(q.number()); } || requires { std::ceil(q.number()); }) && + (std::same_as || requires { + ::units::quantity_cast(q); + quantity::one(); + }) { const auto handle_signed_results = [&](const T& res) { if (res < q) { @@ -223,20 +217,17 @@ template } return res; }; - if constexpr(treat_as_floating_point) { + if constexpr (treat_as_floating_point) { using std::ceil; - if constexpr(std::is_same_v) { + if constexpr (std::is_same_v) { return quantity(ceil(q.number())); - } - else { + } else { return handle_signed_results(quantity(ceil(quantity_cast(q).number()))); } - } - else { - if constexpr(std::is_same_v) { + } else { + if constexpr (std::is_same_v) { return q; - } - else { + } else { return handle_signed_results(quantity_cast(q)); } } @@ -265,24 +256,21 @@ template D, typename U, std::s */ template [[nodiscard]] constexpr quantity round(const quantity& q) noexcept - requires ((!treat_as_floating_point) || - requires { round(q.number()); } || - requires { std::round(q.number()); }) && - (std::same_as || requires { - ::units::floor(q); - quantity::one(); - }) + requires((!treat_as_floating_point) || requires { round(q.number()); } || + requires { std::round(q.number()); }) && + (std::same_as || requires { + ::units::floor(q); + quantity::one(); + }) { - if constexpr(std::is_same_v) { - if constexpr(treat_as_floating_point) { + if constexpr (std::is_same_v) { + if constexpr (treat_as_floating_point) { using std::round; return quantity(round(q.number())); - } - else { + } else { return q; } - } - else { + } else { const auto res_low = units::floor(q); const auto res_high = res_low + decltype(res_low)::one(); const auto diff0 = q - res_low; diff --git a/src/core/include/units/prefix.h b/src/core/include/units/prefix.h index 121d9379..0a9386d1 100644 --- a/src/core/include/units/prefix.h +++ b/src/core/include/units/prefix.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include // IWYU pragma: begin_exports #include #include @@ -72,7 +72,7 @@ struct prefix_base : downcast_base> { * @tparam R factor to be used to scale a unit */ template - requires (!std::same_as) + requires(!std::same_as) struct prefix : downcast_dispatch, downcast_mode::on> { static constexpr auto symbol = Symbol; }; diff --git a/src/core/include/units/quantity.h b/src/core/include/units/quantity.h index 6c2daab5..8b5056a4 100644 --- a/src/core/include/units/quantity.h +++ b/src/core/include/units/quantity.h @@ -48,50 +48,38 @@ inline constexpr auto make_quantity = [](auto&& v) { } // namespace detail template -concept floating_point_ = // exposition only - (Quantity && treat_as_floating_point) || - (!Quantity && treat_as_floating_point); +concept floating_point_ = // exposition only + (Quantity && treat_as_floating_point) || (!Quantity && treat_as_floating_point); template -concept safe_convertible_to_ = // exposition only - (!Quantity) && - (!Quantity) && - std::convertible_to && - (floating_point_ || (!floating_point_)); +concept safe_convertible_to_ = // exposition only + (!Quantity) && (!Quantity) && std::convertible_to && + (floating_point_ || (!floating_point_)); // QFrom ratio is an exact multiple of QTo template -concept harmonic_ = // exposition only - Quantity && - Quantity && - is_integral(detail::quantity_ratio / detail::quantity_ratio); +concept harmonic_ = // exposition only + Quantity && Quantity && is_integral(detail::quantity_ratio / detail::quantity_ratio); template -concept safe_castable_to_ = // exposition only - Quantity && - QuantityOf && - scalable_with_ && - (floating_point_ || (!floating_point_ && harmonic_)); +concept safe_castable_to_ = // exposition only + Quantity && QuantityOf && + scalable_with_ && + (floating_point_ || (!floating_point_ && harmonic_)); template -concept quantity_value_for_ = - std::regular_invocable && - Representation>; +concept quantity_value_for_ = std::regular_invocable && Representation>; template concept invoke_result_convertible_to_ = - Representation && - quantity_value_for_ && - safe_convertible_to_>; + Representation && quantity_value_for_ && safe_convertible_to_>; template -concept have_quantity_for_ = - Quantity && - (!Quantity) && - quantity_value_for_; +concept have_quantity_for_ = Quantity && (!Quantity) && quantity_value_for_; template -using quantity_like_type = quantity::dimension, typename quantity_like_traits::unit, typename quantity_like_traits::rep>; +using quantity_like_type = quantity::dimension, typename quantity_like_traits::unit, + typename quantity_like_traits::rep>; /** * @brief A quantity @@ -144,76 +132,110 @@ public: quantity(quantity&&) = default; template - requires safe_convertible_to_, rep> - constexpr explicit(!(std::same_as && std::same_as)) - quantity(Value&& v) : number_(std::forward(v)) {} + requires(safe_convertible_to_, rep>) + constexpr explicit(!(std::same_as && std::same_as)) quantity(Value&& v) : + number_(std::forward(v)) + { + } template Q> - constexpr explicit(false) quantity(const Q& q) : number_(quantity_cast(q).number()) {} + constexpr explicit(false) quantity(const Q& q) : number_(quantity_cast(q).number()) + { + } template - requires safe_castable_to_, quantity> - constexpr explicit quantity(const Q& q) : quantity(quantity_like_type(quantity_like_traits::number(q))) {} + requires(safe_castable_to_, quantity>) + constexpr explicit quantity(const Q& q) : quantity(quantity_like_type(quantity_like_traits::number(q))) + { + } quantity& operator=(const quantity&) = default; quantity& operator=(quantity&&) = default; // data access [[nodiscard]] constexpr rep& number() & noexcept { return number_; } - [[nodiscard]] constexpr const rep& number() const & noexcept { return number_; } + [[nodiscard]] constexpr const rep& number() const& noexcept { return number_; } [[nodiscard]] constexpr rep&& number() && noexcept { return std::move(number_); } - [[nodiscard]] constexpr const rep&& number() const && noexcept { return std::move(number_); } + [[nodiscard]] constexpr const rep&& number() const&& noexcept { return std::move(number_); } // member unary operators [[nodiscard]] constexpr Quantity auto operator+() const - requires requires(rep v) { { +v } -> std::common_with; } + requires requires(rep v) { + { + +v + } -> std::common_with; + } { using ret = quantity; return ret(+number()); } [[nodiscard]] constexpr Quantity auto operator-() const - requires std::regular_invocable, rep> + requires(std::regular_invocable, rep>) { using ret = quantity; return ret(-number()); } constexpr quantity& operator++() - requires requires(rep v) { { ++v } -> std::same_as; } + requires requires(rep v) { + { + ++v + } -> std::same_as; + } { ++number_; return *this; } [[nodiscard]] constexpr quantity operator++(int) - requires requires(rep v) { { v++ } -> std::same_as; } + requires requires(rep v) { + { + v++ + } -> std::same_as; + } { return quantity(number_++); } constexpr quantity& operator--() - requires requires(rep v) { { --v } -> std::same_as; } + requires requires(rep v) { + { + --v + } -> std::same_as; + } { --number_; return *this; } [[nodiscard]] constexpr quantity operator--(int) - requires requires(rep v) { { v-- } -> std::same_as; } + requires requires(rep v) { + { + v-- + } -> std::same_as; + } { return quantity(number_--); } constexpr quantity& operator+=(const quantity& q) - requires requires(rep a, rep b) { { a += b } -> std::same_as; } + requires requires(rep a, rep b) { + { + a += b + } -> std::same_as; + } { number_ += q.number(); return *this; } constexpr quantity& operator-=(const quantity& q) - requires requires(rep a, rep b) { { a -= b } -> std::same_as; } + requires requires(rep a, rep b) { + { + a -= b + } -> std::same_as; + } { number_ -= q.number(); return *this; @@ -221,14 +243,22 @@ public: template constexpr quantity& operator*=(const Rep2& rhs) - requires requires(rep a, const Rep2 b) { { a *= b } -> std::same_as; } + requires requires(rep a, const Rep2 b) { + { + a *= b + } -> std::same_as; + } { number_ *= rhs; return *this; } template constexpr quantity& operator*=(const dimensionless& rhs) - requires requires(rep a, const Rep2 b) { { a *= b } -> std::same_as; } + requires requires(rep a, const Rep2 b) { + { + a *= b + } -> std::same_as; + } { number_ *= rhs.number(); return *this; @@ -236,7 +266,11 @@ public: template constexpr quantity& operator/=(const Rep2& rhs) - requires requires(rep a, const Rep2 b) { { a /= b } -> std::same_as; } + requires requires(rep a, const Rep2 b) { + { + a /= b + } -> std::same_as; + } { gsl_ExpectsAudit(rhs != quantity_values::zero()); number_ /= rhs; @@ -244,7 +278,11 @@ public: } template constexpr quantity& operator/=(const dimensionless& rhs) - requires requires(rep a, const Rep2 b) { { a /= b } -> std::same_as; } + requires requires(rep a, const Rep2 b) { + { + a /= b + } -> std::same_as; + } { gsl_ExpectsAudit(rhs.number() != quantity_values::zero()); number_ /= rhs.number(); @@ -253,8 +291,11 @@ public: template constexpr quantity& operator%=(const Rep2& rhs) - requires (!floating_point_) && (!floating_point_) && - requires(rep a, const Rep2 b) { { a %= b } -> std::same_as; } + requires(!floating_point_) && (!floating_point_) && requires(rep a, const Rep2 b) { + { + a %= b + } -> std::same_as; + } { gsl_ExpectsAudit(rhs != quantity_values::zero()); number_ %= rhs; @@ -263,8 +304,11 @@ public: template constexpr quantity& operator%=(const dimensionless& rhs) - requires (!floating_point_) && (!floating_point_) && - requires(rep a, const Rep2 b) { { a %= b } -> std::same_as; } + requires(!floating_point_) && (!floating_point_) && requires(rep a, const Rep2 b) { + { + a %= b + } -> std::same_as; + } { gsl_ExpectsAudit(rhs.number() != quantity_values::zero()); number_ %= rhs.number(); @@ -272,8 +316,11 @@ public: } constexpr quantity& operator%=(const quantity& q) - requires (!floating_point_) && - requires(rep a, rep b) { { a %= b } -> std::same_as; } + requires(!floating_point_) && requires(rep a, rep b) { + { + a %= b + } -> std::same_as; + } { gsl_ExpectsAudit(q.number() != quantity_values::zero()); number_ %= q.number(); @@ -284,36 +331,48 @@ public: // Below friend functions are to be found via argument-dependent lookup only template [[nodiscard]] friend constexpr Quantity auto operator+(const quantity& lhs, const Value& rhs) - requires requires { requires !Quantity; requires is_same_v; // TODO: Simplify - requires invoke_result_convertible_to_, rep, Value>; } // when Clang catches up. + requires requires { + requires !Quantity; + requires is_same_v; // TODO: Simplify + requires invoke_result_convertible_to_, rep, Value>; + } // when Clang catches up. { return units::quantity(lhs.number() + rhs); } template [[nodiscard]] friend constexpr Quantity auto operator+(const Value& lhs, const quantity& rhs) - requires requires { requires !Quantity; requires is_same_v; // TODO: Simplify - requires invoke_result_convertible_to_, Value, rep>; } // when Clang catches up. + requires requires { + requires !Quantity; + requires is_same_v; // TODO: Simplify + requires invoke_result_convertible_to_, Value, rep>; + } // when Clang catches up. { return units::quantity(lhs + rhs.number()); } template [[nodiscard]] friend constexpr Quantity auto operator-(const quantity& lhs, const Value& rhs) - requires requires { requires !Quantity; requires is_same_v; // TODO: Simplify - requires invoke_result_convertible_to_, rep, Value>; } // when Clang catches up. + requires requires { + requires !Quantity; + requires is_same_v; // TODO: Simplify + requires invoke_result_convertible_to_, rep, Value>; + } // when Clang catches up. { return units::quantity(lhs.number() - rhs); } template [[nodiscard]] friend constexpr Quantity auto operator-(const Value& lhs, const quantity& rhs) - requires requires { requires !Quantity; requires is_same_v; // TODO: Simplify - requires invoke_result_convertible_to_, Value, rep>; } // when Clang catches up. + requires requires { + requires !Quantity; + requires is_same_v; // TODO: Simplify + requires invoke_result_convertible_to_, Value, rep>; + } // when Clang catches up. { return units::quantity(lhs - rhs.number()); } template - requires invoke_result_convertible_to_, rep, const Value&> + requires(invoke_result_convertible_to_, rep, const Value&>) [[nodiscard]] friend constexpr Quantity auto operator*(const quantity& q, const Value& v) { using ret = quantity, rep, Value>>; @@ -321,7 +380,7 @@ public: } template - requires invoke_result_convertible_to_, const Value&, rep> + requires(invoke_result_convertible_to_, const Value&, rep>) [[nodiscard]] friend constexpr Quantity auto operator*(const Value& v, const quantity& q) { using ret = quantity, Value, rep>>; @@ -329,8 +388,7 @@ public: } template - requires (!Quantity) && - invoke_result_convertible_to_, rep, const Value&> + requires(!Quantity) && (invoke_result_convertible_to_, rep, const Value&>) [[nodiscard]] friend constexpr Quantity auto operator/(const quantity& q, const Value& v) { gsl_ExpectsAudit(v != quantity_values::zero()); @@ -339,8 +397,7 @@ public: } template - requires (!Quantity) && - invoke_result_convertible_to_, const Value&, rep> + requires(!Quantity) && (invoke_result_convertible_to_, const Value&, rep>) [[nodiscard]] friend constexpr Quantity auto operator/(const Value& v, const quantity& q) { gsl_ExpectsAudit(q.number() != quantity_values::zero()); @@ -351,8 +408,8 @@ public: } template - requires (!Quantity) && (!floating_point_) && (!floating_point_) && - invoke_result_convertible_to_, rep, const Value&> + requires(!Quantity) && (!floating_point_) && (!floating_point_) && + (invoke_result_convertible_to_, rep, const Value&>) [[nodiscard]] friend constexpr Quantity auto operator%(const quantity& q, const Value& v) { gsl_ExpectsAudit(v != quantity_values::zero()); @@ -361,8 +418,7 @@ public: } [[nodiscard]] friend constexpr Quantity auto operator%(const quantity& lhs, const quantity& rhs) - requires (!floating_point_) && - invoke_result_convertible_to_, rep, rep> + requires(!floating_point_) && (invoke_result_convertible_to_, rep, rep>) { gsl_ExpectsAudit(rhs.number() != quantity_values::zero()); using ret = quantity, rep, rep>>; @@ -385,18 +441,19 @@ public: // CTAD #if !UNITS_COMP_CLANG || UNITS_COMP_CLANG > 15 template -explicit(false) quantity(Rep&&) -> quantity; +explicit(false) quantity(Rep&&)->quantity; #endif template -explicit(false) quantity(Rep) -> quantity; +explicit(false) quantity(Rep)->quantity; template -explicit quantity(Q) -> quantity::dimension, typename quantity_like_traits::unit, typename quantity_like_traits::rep>; +explicit quantity(Q) -> quantity::dimension, typename quantity_like_traits::unit, + typename quantity_like_traits::rep>; // non-member binary operators template Q2> - requires quantity_value_for_, typename Q1::rep, typename Q2::rep> + requires(quantity_value_for_, typename Q1::rep, typename Q2::rep>) [[nodiscard]] constexpr Quantity auto operator+(const Q1& lhs, const Q2& rhs) { using ref = detail::common_quantity_reference; @@ -405,7 +462,7 @@ template Q2> } template Q2> - requires quantity_value_for_, typename Q1::rep, typename Q2::rep> + requires(quantity_value_for_, typename Q1::rep, typename Q2::rep>) [[nodiscard]] constexpr Quantity auto operator-(const Q1& lhs, const Q2& rhs) { using ref = detail::common_quantity_reference; @@ -414,14 +471,14 @@ template Q2> } template - requires quantity_value_for_, typename Q1::rep, typename Q2::rep> + requires(quantity_value_for_, typename Q1::rep, typename Q2::rep>) [[nodiscard]] constexpr Quantity auto operator*(const Q1& lhs, const Q2& rhs) { return detail::make_quantity(lhs.number() * rhs.number()); } template - requires quantity_value_for_, typename Q1::rep, typename Q2::rep> + requires(quantity_value_for_, typename Q1::rep, typename Q2::rep>) [[nodiscard]] constexpr Quantity auto operator/(const Q1& lhs, const Q2& rhs) { gsl_ExpectsAudit(rhs.number() != quantity_values::zero()); @@ -429,13 +486,14 @@ template } template - requires (!floating_point_) && (!floating_point_) && + requires(!floating_point_) && (!floating_point_) && (QuantityEquivalentTo || Dimensionless) && - quantity_value_for_, typename Q1::rep, typename Q2::rep> + (quantity_value_for_, typename Q1::rep, typename Q2::rep>) [[nodiscard]] constexpr Quantity auto operator%(const Q1& lhs, const Q2& rhs) { gsl_ExpectsAudit(rhs.number() != quantity_values::zero()); - using ret = quantity, typename Q1::rep, typename Q2::rep>>; + using ret = quantity, typename Q1::rep, typename Q2::rep>>; return ret(lhs.number() % rhs.number()); } @@ -462,7 +520,7 @@ template inline constexpr bool is_quantity> = true; template -requires units::is_derived_from_specialization_of + requires units::is_derived_from_specialization_of inline constexpr bool is_quantity = true; } // namespace detail diff --git a/src/core/include/units/quantity_cast.h b/src/core/include/units/quantity_cast.h index 8f33c47c..5657d421 100644 --- a/src/core/include/units/quantity_cast.h +++ b/src/core/include/units/quantity_cast.h @@ -22,14 +22,15 @@ #pragma once -#include -#include #include #include #include +#include +#include UNITS_DIAGNOSTIC_PUSH -UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA // warning C4244: 'argument': conversion from 'intmax_t' to 'T', possible loss of data with T=int +// warning C4244: 'argument': conversion from 'intmax_t' to 'T', possible loss of data with T=int +UNITS_DIAGNOSTIC_IGNORE_LOSS_OF_DATA namespace units { @@ -48,28 +49,24 @@ class quantity_point_kind; namespace detail { template - inline constexpr ratio quantity_ratio = std::enable_if_t>{}; +inline constexpr ratio quantity_ratio = std::enable_if_t>{}; template -inline constexpr ratio quantity_ratio> = [] -{ - if constexpr(BaseDimension) { +inline constexpr ratio quantity_ratio> = [] { + if constexpr (BaseDimension) { return U::ratio; - } - else { + } else { return D::base_units_ratio * U::ratio / D::coherent_unit::ratio; } }(); template -inline constexpr ratio cast_ratio = [] -{ +inline constexpr ratio cast_ratio = [] { using FromU = TYPENAME QFrom::unit; using ToU = TYPENAME QTo::unit; - if constexpr(same_unit_reference::value) { + if constexpr (same_unit_reference::value) { return FromU::ratio / ToU::ratio; - } - else { + } else { return quantity_ratio / quantity_ratio; } }(); @@ -78,18 +75,17 @@ template struct cast_traits; template - requires common_type_with_, std::intmax_t> -struct cast_traits { + requires common_type_with_, + std::intmax_t> struct cast_traits { using ratio_type = std::common_type_t, std::intmax_t>; using rep_type = ratio_type; }; template - requires (!common_type_with_, std::intmax_t>) && - scalable_number_, std::intmax_t> && - requires { typename std::common_type_t::value_type; } && - common_type_with_::value_type, std::intmax_t> -struct cast_traits { + requires(!common_type_with_, std::intmax_t>) && + scalable_number_, + std::intmax_t>&& requires { typename std::common_type_t::value_type; } && + common_type_with_::value_type, std::intmax_t> struct cast_traits { using ratio_type = std::common_type_t::value_type, std::intmax_t>; using rep_type = std::common_type_t; }; @@ -109,7 +105,7 @@ struct cast_traits { * @tparam To a target quantity type to cast to */ template Rep> - requires QuantityOf && std::constructible_from> + requires QuantityOf && (std::constructible_from>) [[nodiscard]] constexpr auto quantity_cast(const quantity& q) { using traits = detail::cast_traits; @@ -118,19 +114,20 @@ template R constexpr auto c_ratio = detail::cast_ratio, To>; if constexpr (treat_as_floating_point) { - return To(static_cast(static_cast(q.number()) * - (static_cast(c_ratio.num) * detail::fpow10(c_ratio.exp) / static_cast(c_ratio.den)))); - } - else { + return To( + static_cast(static_cast(q.number()) * + (static_cast(c_ratio.num) * detail::fpow10(c_ratio.exp) / + static_cast(c_ratio.den)))); + } else { if constexpr (c_ratio.exp > 0) { - return To(static_cast(static_cast(q.number()) * - (static_cast(c_ratio.num) * static_cast(detail::ipow10(c_ratio.exp))) / - static_cast(c_ratio.den))); - } - else { - return To(static_cast(static_cast(q.number()) * - static_cast(c_ratio.num) / - (static_cast(c_ratio.den) * static_cast(detail::ipow10(-c_ratio.exp))))); + return To(static_cast( + static_cast(q.number()) * + (static_cast(c_ratio.num) * static_cast(detail::ipow10(c_ratio.exp))) / + static_cast(c_ratio.den))); + } else { + return To(static_cast( + static_cast(q.number()) * static_cast(c_ratio.num) / + (static_cast(c_ratio.den) * static_cast(detail::ipow10(-c_ratio.exp))))); } } } @@ -209,7 +206,7 @@ template * @tparam ToRep a representation type to use for a target quantity */ template Rep> - requires std::constructible_from> + requires(std::constructible_from>) [[nodiscard]] constexpr auto quantity_cast(const quantity& q) { return quantity_cast>(q); @@ -233,9 +230,11 @@ template Rep */ template [[nodiscard]] constexpr auto quantity_point_cast(const quantity_point& qp) - requires requires { requires is_specialization_of; - requires requires { quantity_cast(qp.relative()); }; - requires equivalent; } || // TODO: Simplify when Clang catches up. + requires requires { + requires is_specialization_of; + requires requires { quantity_cast(qp.relative()); }; + requires equivalent; + } || // TODO: Simplify when Clang catches up. requires { quantity_cast(qp.relative()); } { if constexpr (is_specialization_of) @@ -286,10 +285,13 @@ template */ template [[nodiscard]] constexpr QuantityKind auto quantity_kind_cast(const quantity_kind& qk) - requires requires { requires is_specialization_of; - requires requires { quantity_cast(qk.common()); }; } || - requires { requires Kind; requires UnitOf; } || - requires { quantity_cast(qk.common()); } // TODO: Simplify when Clang catches up. + requires requires { + requires is_specialization_of; + requires requires { quantity_cast(qk.common()); }; + } || requires { + requires Kind; + requires UnitOf; + } || requires { quantity_cast(qk.common()); } // TODO: Simplify when Clang catches up. { if constexpr (is_specialization_of) return CastSpec(quantity_cast(qk.common())); @@ -330,25 +332,27 @@ template * Implicit conversions between quantity point kinds of different types are allowed only for "safe" * (i.e. non-truncating) conversion. In other cases an explicit cast has to be used. * - * This cast gets the target (quantity) point kind type to cast to or anything that works for quantity_kind_cast. For example: + * This cast gets the target (quantity) point kind type to cast to or anything that works for quantity_kind_cast. For + * example: * * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * mm}); * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * mm}); * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * m}); * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * m}); * auto q1 = units::quantity_point_kind_cast>(ns::x_coordinate{1 * mm}); - * auto q1 = units::quantity_point_kind_cast(quantity_point_kind(ns::rate_of_climb{200 * Gal})); - * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * mm}); - * auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1.0 * mm}); + * auto q1 = units::quantity_point_kind_cast(quantity_point_kind(ns::rate_of_climb{200 + * * Gal})); auto q1 = units::quantity_point_kind_cast(ns::x_coordinate{1 * mm}); auto q1 = + * units::quantity_point_kind_cast(ns::x_coordinate{1.0 * mm}); * * @tparam CastSpec a target (quantity) point kind type to cast to or anything that works for quantity_kind_cast */ template [[nodiscard]] constexpr QuantityPointKind auto quantity_point_kind_cast(const quantity_point_kind& qpk) - requires requires { requires is_specialization_of; - requires requires { quantity_kind_cast(qpk.relative()); }; - requires equivalent; } || - requires { requires PointKind && UnitOf; } || + requires requires { + requires is_specialization_of; + requires requires { quantity_kind_cast(qpk.relative()); }; + requires equivalent; + } || requires { requires PointKind && UnitOf; } || requires { quantity_kind_cast(qpk.relative()); } // TODO: Simplify when Clang catches up. { if constexpr (is_specialization_of) diff --git a/src/core/include/units/quantity_kind.h b/src/core/include/units/quantity_kind.h index 50c3f785..a4bcc594 100644 --- a/src/core/include/units/quantity_kind.h +++ b/src/core/include/units/quantity_kind.h @@ -63,7 +63,7 @@ inline constexpr auto& downcasted_kind = downcasted_kind_fn concept QuantityKindRelatedTo = QuantityKind && QuantityKind && - equivalent; + equivalent; /** * @brief A quantity kind @@ -94,24 +94,26 @@ public: quantity_kind(quantity_kind&&) = default; template - requires - (Quantity> || - QuantityLike> || - (Dimensionless && !Quantity>)) && - std::constructible_from - constexpr explicit quantity_kind(T&& t) : q_(std::forward(t)) {} + requires(Quantity> || QuantityLike> || + (Dimensionless && !Quantity>)) && + std::constructible_from + constexpr explicit quantity_kind(T&& t) : q_(std::forward(t)) + { + } template QK2> requires std::convertible_to - constexpr explicit(false) quantity_kind(const QK2& qk) : q_(qk.common()) {} + constexpr explicit(false) quantity_kind(const QK2& qk) : q_(qk.common()) + { + } quantity_kind& operator=(const quantity_kind&) = default; quantity_kind& operator=(quantity_kind&&) = default; [[nodiscard]] constexpr quantity_type& common() & noexcept { return q_; } - [[nodiscard]] constexpr const quantity_type& common() const & noexcept { return q_; } + [[nodiscard]] constexpr const quantity_type& common() const& noexcept { return q_; } [[nodiscard]] constexpr quantity_type&& common() && noexcept { return std::move(q_); } - [[nodiscard]] constexpr const quantity_type&& common() const && noexcept { return std::move(q_); } + [[nodiscard]] constexpr const quantity_type&& common() const&& noexcept { return std::move(q_); } [[nodiscard]] static constexpr quantity_kind zero() noexcept requires requires { quantity_type::zero(); } @@ -222,17 +224,18 @@ public: template constexpr quantity_kind& operator%=(const Rep2& rhs) - requires (!Quantity || Dimensionless) && requires(quantity_type q, const Rep2 r) { q %= r; } + requires(!Quantity || Dimensionless) && requires(quantity_type q, const Rep2 r) { q %= r; } { gsl_ExpectsAudit(rhs != quantity_values::zero()); q_ %= rhs; return *this; } - + template constexpr quantity_kind& operator%=(const QK& rhs) - requires (QuantityKindEquivalentTo || std::same_as>) && - requires(quantity_type q) { q %= rhs.common(); } + requires(QuantityKindEquivalentTo || + std::same_as>) && + requires(quantity_type q) { q %= rhs.common(); } { gsl_ExpectsAudit(rhs.common().number() != quantity_values::zero()); q_ %= rhs.common(); @@ -243,21 +246,33 @@ public: // Below friend functions are to be found via argument-dependent lookup only template [[nodiscard]] friend constexpr QuantityKind auto operator*(const quantity_kind& qk, const Value& v) - requires requires(quantity_type q) { { q * v } -> Quantity; } + requires requires(quantity_type q) { + { + q* v + } -> Quantity; + } { return detail::make_quantity_kind(qk.common() * v); } template [[nodiscard]] friend constexpr QuantityKind auto operator*(const Value& v, const quantity_kind& qk) - requires requires(quantity_type q) { { v * q } -> Quantity; } + requires requires(quantity_type q) { + { + v* q + } -> Quantity; + } { return detail::make_quantity_kind(v * qk.common()); } template [[nodiscard]] friend constexpr QuantityKind auto operator/(const quantity_kind& qk, const Value& v) - requires requires(quantity_type q) { { q / v } -> Quantity; } + requires requires(quantity_type q) { + { + q / v + } -> Quantity; + } { gsl_ExpectsAudit(v != quantity_values::zero()); return detail::make_quantity_kind(qk.common() / v); @@ -265,7 +280,11 @@ public: template [[nodiscard]] friend constexpr QuantityKind auto operator/(const Value& v, const quantity_kind& qk) - requires requires(quantity_type q) { { v / q } -> Quantity; } + requires requires(quantity_type q) { + { + v / q + } -> Quantity; + } { gsl_ExpectsAudit(qk.common().number() != quantity_values::zero()); return detail::downcasted_kind(v / qk.common()); @@ -297,7 +316,7 @@ template QK2> template QK2> [[nodiscard]] constexpr QuantityKind auto operator-(const QK1& lhs, const QK2& rhs) - requires requires { lhs.common() - rhs.common(); } + requires requires { lhs.common() - rhs.common(); } { return detail::make_quantity_kind(lhs.common() - rhs.common()); } @@ -311,7 +330,7 @@ template template [[nodiscard]] constexpr QuantityKind auto operator*(const Q& lhs, const QK& rhs) - requires requires { lhs * rhs.common(); } + requires requires { lhs* rhs.common(); } { return detail::downcasted_kind(lhs * rhs.common()); } diff --git a/src/core/include/units/quantity_point.h b/src/core/include/units/quantity_point.h index 4da06901..bd3fa2fc 100644 --- a/src/core/include/units/quantity_point.h +++ b/src/core/include/units/quantity_point.h @@ -76,25 +76,31 @@ public: template requires std::constructible_from - constexpr explicit quantity_point(T&& t) : q_(std::forward(t)) {} + constexpr explicit quantity_point(T&& t) : q_(std::forward(t)) + { + } template QP2> requires std::convertible_to - constexpr explicit(false) quantity_point(const QP2& qp) : q_(qp.relative()) {} + constexpr explicit(false) quantity_point(const QP2& qp) : q_(qp.relative()) + { + } template constexpr explicit quantity_point(const QP& qp) requires std::is_constructible_v::relative(qp))> && - equivalent::origin> - : q_(quantity_point_like_traits::relative(qp)) {} + equivalent::origin> + : q_(quantity_point_like_traits::relative(qp)) + { + } quantity_point& operator=(const quantity_point&) = default; quantity_point& operator=(quantity_point&&) = default; [[nodiscard]] constexpr quantity_type& relative() & noexcept { return q_; } - [[nodiscard]] constexpr const quantity_type& relative() const & noexcept { return q_; } + [[nodiscard]] constexpr const quantity_type& relative() const& noexcept { return q_; } [[nodiscard]] constexpr quantity_type&& relative() && noexcept { return std::move(q_); } - [[nodiscard]] constexpr const quantity_type&& relative() const && noexcept { return std::move(q_); } + [[nodiscard]] constexpr const quantity_type&& relative() const&& noexcept { return std::move(q_); } [[nodiscard]] static constexpr quantity_point min() noexcept requires requires { quantity_type::min(); } @@ -207,13 +213,14 @@ template explicit quantity_point(Q) -> quantity_point, typename Q::unit, typename Q::rep>; template -explicit quantity_point(Q) -> quantity_point::dimension>, - typename quantity_like_traits::unit, typename quantity_like_traits::rep>; +explicit quantity_point(Q) + -> quantity_point::dimension>, typename quantity_like_traits::unit, + typename quantity_like_traits::rep>; template -explicit quantity_point(QP) -> quantity_point::origin, - typename quantity_point_like_traits::unit, - typename quantity_point_like_traits::rep>; +explicit quantity_point(QP) + -> quantity_point::origin, typename quantity_point_like_traits::unit, + typename quantity_point_like_traits::rep>; namespace detail { diff --git a/src/core/include/units/quantity_point_kind.h b/src/core/include/units/quantity_point_kind.h index a2c5f1a1..837ab301 100644 --- a/src/core/include/units/quantity_point_kind.h +++ b/src/core/include/units/quantity_point_kind.h @@ -63,26 +63,32 @@ public: template requires std::constructible_from - constexpr explicit quantity_point_kind(T&& t) : qk_(std::forward(t)) {} + constexpr explicit quantity_point_kind(T&& t) : qk_(std::forward(t)) + { + } constexpr explicit quantity_point_kind(const quantity_point& qp) : qk_(qp.relative()) {} constexpr explicit quantity_point_kind(quantity_point&& qp) : qk_(std::move(qp).relative()) {} template - requires std::constructible_from, QP> - constexpr explicit quantity_point_kind(const QP& qp) : qk_(quantity_point_like_traits::relative(qp)) {} + requires(std::constructible_from, QP>) + constexpr explicit quantity_point_kind(const QP& qp) : qk_(quantity_point_like_traits::relative(qp)) + { + } template QPK2> requires std::convertible_to - constexpr explicit(false) quantity_point_kind(const QPK2& qpk) : qk_(qpk.relative()) {} + constexpr explicit(false) quantity_point_kind(const QPK2& qpk) : qk_(qpk.relative()) + { + } quantity_point_kind& operator=(const quantity_point_kind&) = default; quantity_point_kind& operator=(quantity_point_kind&&) = default; [[nodiscard]] constexpr quantity_kind_type& relative() & noexcept { return qk_; } - [[nodiscard]] constexpr const quantity_kind_type& relative() const & noexcept { return qk_; } + [[nodiscard]] constexpr const quantity_kind_type& relative() const& noexcept { return qk_; } [[nodiscard]] constexpr quantity_kind_type&& relative() && noexcept { return std::move(qk_); } - [[nodiscard]] constexpr const quantity_kind_type&& relative() const && noexcept { return std::move(qk_); } + [[nodiscard]] constexpr const quantity_kind_type&& relative() const&& noexcept { return std::move(qk_); } [[nodiscard]] static constexpr quantity_point_kind min() noexcept requires requires { quantity_kind_type::min(); } @@ -180,12 +186,11 @@ public: { return lhs.relative() == rhs.relative(); } - }; template -quantity_point_kind(QK) -> - quantity_point_kind, typename QK::unit, typename QK::rep>; +quantity_point_kind(QK) + -> quantity_point_kind, typename QK::unit, typename QK::rep>; namespace detail { diff --git a/src/core/include/units/random.h b/src/core/include/units/random.h index 05e42e5e..4711695b 100644 --- a/src/core/include/units/random.h +++ b/src/core/include/units/random.h @@ -23,460 +23,534 @@ #pragma once #include -#include #include +#include namespace units { namespace detail { - template - static std::vector i_qty_to_rep(InputIt first, InputIt last) - { - std::vector intervals_rep; - intervals_rep.reserve(static_cast(std::distance(first, last))); - for (auto itr = first; itr != last; ++itr) { intervals_rep.push_back(itr->number()); } - return intervals_rep; - } - - template - static std::vector bl_qty_to_rep(std::initializer_list& bl) - { - std::vector bl_rep; - bl_rep.reserve(bl.size()); - for (const Q& qty : bl) { bl_rep.push_back(qty.number()); } - return bl_rep; - } - - template - inline static std::vector fw_bl_pwc(std::initializer_list& bl, UnaryOperation fw) - { - using rep = TYPENAME Q::rep; - std::vector w_bl; - w_bl.reserve(bl.size()); - for (const Q& qty : bl) { w_bl.push_back(fw(qty)); } - std::vector weights; - weights.reserve(bl.size()); - for (size_t i = 0; i < bl.size() - 1; ++i) { weights.push_back(w_bl[i] + w_bl[i + 1]); } - weights.push_back(0); - return weights; - } - - template - static std::vector fw_bl_pwl(std::initializer_list& bl, UnaryOperation fw) - { - std::vector weights; - weights.reserve(bl.size()); - for (const Q& qty : bl) { weights.push_back(fw(qty)); } - return weights; - } -} // namespace detail +template +static std::vector i_qty_to_rep(InputIt first, InputIt last) +{ + std::vector intervals_rep; + intervals_rep.reserve(static_cast(std::distance(first, last))); + for (auto itr = first; itr != last; ++itr) { + intervals_rep.push_back(itr->number()); + } + return intervals_rep; +} template - requires std::integral -struct uniform_int_distribution : public std::uniform_int_distribution +static std::vector bl_qty_to_rep(std::initializer_list& bl) { - using rep = TYPENAME Q::rep; - using base = TYPENAME std::uniform_int_distribution; - - uniform_int_distribution() : base() {} - uniform_int_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q a() const { return Q(base::a()); } - Q b() const { return Q(base::b()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + std::vector bl_rep; + bl_rep.reserve(bl.size()); + for (const Q& qty : bl) { + bl_rep.push_back(qty.number()); + } + return bl_rep; +} + +template +inline static std::vector fw_bl_pwc(std::initializer_list& bl, UnaryOperation fw) +{ + using rep = TYPENAME Q::rep; + std::vector w_bl; + w_bl.reserve(bl.size()); + for (const Q& qty : bl) { + w_bl.push_back(fw(qty)); + } + std::vector weights; + weights.reserve(bl.size()); + for (size_t i = 0; i < bl.size() - 1; ++i) { + weights.push_back(w_bl[i] + w_bl[i + 1]); + } + weights.push_back(0); + return weights; +} + +template +static std::vector fw_bl_pwl(std::initializer_list& bl, UnaryOperation fw) +{ + std::vector weights; + weights.reserve(bl.size()); + for (const Q& qty : bl) { + weights.push_back(fw(qty)); + } + return weights; +} +} // namespace detail + +template + requires std::integral +struct uniform_int_distribution : public std::uniform_int_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::uniform_int_distribution; + + uniform_int_distribution() : base() {} + uniform_int_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q a() const { return Q(base::a()); } + Q b() const { return Q(base::b()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct uniform_real_distribution : public std::uniform_real_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::uniform_real_distribution; - - uniform_real_distribution() : base() {} - uniform_real_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q a() const { return Q(base::a()); } - Q b() const { return Q(base::b()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct uniform_real_distribution : public std::uniform_real_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::uniform_real_distribution; + + uniform_real_distribution() : base() {} + uniform_real_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q a() const { return Q(base::a()); } + Q b() const { return Q(base::b()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::integral -struct binomial_distribution : public std::binomial_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::binomial_distribution; - - binomial_distribution() : base() {} - binomial_distribution(const Q& t, double p) : base(t.number(), p) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q t() const { return Q(base::t()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::integral +struct binomial_distribution : public std::binomial_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::binomial_distribution; + + binomial_distribution() : base() {} + binomial_distribution(const Q& t, double p) : base(t.number(), p) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q t() const { return Q(base::t()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::integral -struct negative_binomial_distribution : public std::negative_binomial_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::negative_binomial_distribution; - - negative_binomial_distribution() : base() {} - negative_binomial_distribution(const Q& k, double p) : base(k.number(), p) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q k() const { return Q(base::k()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::integral +struct negative_binomial_distribution : public std::negative_binomial_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::negative_binomial_distribution; + + negative_binomial_distribution() : base() {} + negative_binomial_distribution(const Q& k, double p) : base(k.number(), p) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q k() const { return Q(base::k()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::integral -struct geometric_distribution : public std::geometric_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::geometric_distribution; - - geometric_distribution() : base() {} - geometric_distribution(double p) : base(p) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } + requires std::integral +struct geometric_distribution : public std::geometric_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::geometric_distribution; - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + geometric_distribution() : base() {} + geometric_distribution(double p) : base(p) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::integral -struct poisson_distribution : public std::poisson_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::poisson_distribution; - - poisson_distribution() : base() {} - explicit poisson_distribution(double p) : base(p) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::integral +struct poisson_distribution : public std::poisson_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::poisson_distribution; + + poisson_distribution() : base() {} + explicit poisson_distribution(double p) : base(p) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct exponential_distribution : public std::exponential_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::exponential_distribution; - - exponential_distribution() : base() {} - explicit exponential_distribution(const rep& lambda) : base(lambda) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct exponential_distribution : public std::exponential_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::exponential_distribution; + + exponential_distribution() : base() {} + explicit exponential_distribution(const rep& lambda) : base(lambda) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct gamma_distribution : public std::gamma_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::gamma_distribution; - - gamma_distribution() : base() {} - gamma_distribution(const rep& alpha, const rep& beta) : base(alpha, beta) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct gamma_distribution : public std::gamma_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::gamma_distribution; + + gamma_distribution() : base() {} + gamma_distribution(const rep& alpha, const rep& beta) : base(alpha, beta) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct weibull_distribution : public std::weibull_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::weibull_distribution; - - weibull_distribution() : base() {} - weibull_distribution(const rep& a, const rep& b) : base(a, b) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct weibull_distribution : public std::weibull_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::weibull_distribution; + + weibull_distribution() : base() {} + weibull_distribution(const rep& a, const rep& b) : base(a, b) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct extreme_value_distribution : public std::extreme_value_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::extreme_value_distribution; - - extreme_value_distribution() : base() {} - extreme_value_distribution(const Q& a, const rep& b) : base(a.number(), b) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } + requires std::floating_point +struct extreme_value_distribution : public std::extreme_value_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::extreme_value_distribution; - Q a() const { return Q(base::a()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + extreme_value_distribution() : base() {} + extreme_value_distribution(const Q& a, const rep& b) : base(a.number(), b) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q a() const { return Q(base::a()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct normal_distribution : public std::normal_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::normal_distribution; - - normal_distribution() : base() {} - normal_distribution(const Q& mean, const Q& stddev) : base(mean.number(), stddev.number()) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q mean() const { return Q(base::mean()); } - Q stddev() const { return Q(base::stddev()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct normal_distribution : public std::normal_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::normal_distribution; + + normal_distribution() : base() {} + normal_distribution(const Q& mean, const Q& stddev) : base(mean.number(), stddev.number()) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q mean() const { return Q(base::mean()); } + Q stddev() const { return Q(base::stddev()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct lognormal_distribution : public std::lognormal_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::lognormal_distribution; - - lognormal_distribution() : base() {} - lognormal_distribution(const Q& m, const Q& s) : base(m.number(), s.number()) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q m() const { return Q(base::m()); } - Q s() const { return Q(base::s()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct lognormal_distribution : public std::lognormal_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::lognormal_distribution; + + lognormal_distribution() : base() {} + lognormal_distribution(const Q& m, const Q& s) : base(m.number(), s.number()) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q m() const { return Q(base::m()); } + Q s() const { return Q(base::s()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct chi_squared_distribution : public std::chi_squared_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::chi_squared_distribution; - - chi_squared_distribution() : base() {} - explicit chi_squared_distribution(const rep& n) : base(n) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct chi_squared_distribution : public std::chi_squared_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::chi_squared_distribution; + + chi_squared_distribution() : base() {} + explicit chi_squared_distribution(const rep& n) : base(n) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct cauchy_distribution : public std::cauchy_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::cauchy_distribution; - - cauchy_distribution() : base() {} - cauchy_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q a() const { return Q(base::a()); } - Q b() const { return Q(base::b()); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct cauchy_distribution : public std::cauchy_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::cauchy_distribution; + + cauchy_distribution() : base() {} + cauchy_distribution(const Q& a, const Q& b) : base(a.number(), b.number()) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q a() const { return Q(base::a()); } + Q b() const { return Q(base::b()); } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct fisher_f_distribution : public std::fisher_f_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::fisher_f_distribution; - - fisher_f_distribution() : base() {} - fisher_f_distribution(const rep& m, const rep& n) : base(m, n) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct fisher_f_distribution : public std::fisher_f_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::fisher_f_distribution; + + fisher_f_distribution() : base() {} + fisher_f_distribution(const rep& m, const rep& n) : base(m, n) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -struct student_t_distribution : public std::student_t_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::student_t_distribution; - - student_t_distribution() : base() {} - explicit student_t_distribution(const rep& n) : base(n) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + requires std::floating_point +struct student_t_distribution : public std::student_t_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::student_t_distribution; + + student_t_distribution() : base() {} + explicit student_t_distribution(const rep& n) : base(n) {} + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::integral -struct discrete_distribution : public std::discrete_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::discrete_distribution; - - discrete_distribution() : base() {} - - template - discrete_distribution(InputIt first, InputIt last) : base(first, last) {} + requires std::integral +struct discrete_distribution : public std::discrete_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::discrete_distribution; - discrete_distribution(std::initializer_list weights) : base(weights) {} + discrete_distribution() : base() {} - template - discrete_distribution(std::size_t count, double xmin, double xmax, UnaryOperation unary_op) : - base(count, xmin, xmax, unary_op) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + template + discrete_distribution(InputIt first, InputIt last) : base(first, last) + { + } + + discrete_distribution(std::initializer_list weights) : base(weights) {} + + template + discrete_distribution(std::size_t count, double xmin, double xmax, UnaryOperation unary_op) : + base(count, xmin, xmax, unary_op) + { + } + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -class piecewise_constant_distribution : public std::piecewise_constant_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::piecewise_constant_distribution; - - template - piecewise_constant_distribution(const std::vector& i, InputIt first_w) : - base(i.cbegin(), i.cend(), first_w) {} - - piecewise_constant_distribution(const std::vector& bl, const std::vector& weights) : - base(bl.cbegin(), bl.cend(), weights.cbegin()) {} + requires std::floating_point +class piecewise_constant_distribution : public std::piecewise_constant_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::piecewise_constant_distribution; + + template + piecewise_constant_distribution(const std::vector& i, InputIt first_w) : base(i.cbegin(), i.cend(), first_w) + { + } + + piecewise_constant_distribution(const std::vector& bl, const std::vector& weights) : + base(bl.cbegin(), bl.cend(), weights.cbegin()) + { + } public: - piecewise_constant_distribution() : base() {} - - template - piecewise_constant_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w) : - piecewise_constant_distribution(detail::i_qty_to_rep(first_i, last_i), first_w) {} + piecewise_constant_distribution() : base() {} - template - piecewise_constant_distribution(std::initializer_list bl, UnaryOperation fw) : - piecewise_constant_distribution(detail::bl_qty_to_rep(bl), detail::fw_bl_pwc(bl, fw)) {} + template + piecewise_constant_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w) : + piecewise_constant_distribution(detail::i_qty_to_rep(first_i, last_i), first_w) + { + } - template - piecewise_constant_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) : - base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } + template + piecewise_constant_distribution(std::initializer_list bl, UnaryOperation fw) : + piecewise_constant_distribution(detail::bl_qty_to_rep(bl), detail::fw_bl_pwc(bl, fw)) + { + } - std::vector intervals() const - { - std::vector intervals_rep = base::intervals(); - std::vector intervals_qty; - intervals_qty.reserve(intervals_rep.size()); - for (const rep& val : intervals_rep) { intervals_qty.push_back(Q(val)); } - return intervals_qty; + template + piecewise_constant_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) : + base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) + { + } + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + std::vector intervals() const + { + std::vector intervals_rep = base::intervals(); + std::vector intervals_qty; + intervals_qty.reserve(intervals_rep.size()); + for (const rep& val : intervals_rep) { + intervals_qty.push_back(Q(val)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + return intervals_qty; + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; template - requires std::floating_point -class piecewise_linear_distribution : public std::piecewise_linear_distribution -{ - using rep = TYPENAME Q::rep; - using base = TYPENAME std::piecewise_linear_distribution; - - template - piecewise_linear_distribution(const std::vector& i, InputIt first_w) : - base(i.cbegin(), i.cend(), first_w) {} - - piecewise_linear_distribution(const std::vector& bl, const std::vector& weights) : - base(bl.cbegin(), bl.cend(), weights.cbegin()) {} + requires std::floating_point +class piecewise_linear_distribution : public std::piecewise_linear_distribution { + using rep = TYPENAME Q::rep; + using base = TYPENAME std::piecewise_linear_distribution; + + template + piecewise_linear_distribution(const std::vector& i, InputIt first_w) : base(i.cbegin(), i.cend(), first_w) + { + } + + piecewise_linear_distribution(const std::vector& bl, const std::vector& weights) : + base(bl.cbegin(), bl.cend(), weights.cbegin()) + { + } public: - piecewise_linear_distribution() : base() {} - - template - piecewise_linear_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w) : - piecewise_linear_distribution(detail::i_qty_to_rep(first_i, last_i), first_w) {} + piecewise_linear_distribution() : base() {} - template - piecewise_linear_distribution(std::initializer_list bl, UnaryOperation fw) : - piecewise_linear_distribution(detail::bl_qty_to_rep(bl), detail::fw_bl_pwl(bl, fw)) {} + template + piecewise_linear_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w) : + piecewise_linear_distribution(detail::i_qty_to_rep(first_i, last_i), first_w) + { + } - template - piecewise_linear_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) : - base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) {} - - template - Q operator()(Generator& g) { return Q(base::operator()(g)); } + template + piecewise_linear_distribution(std::initializer_list bl, UnaryOperation fw) : + piecewise_linear_distribution(detail::bl_qty_to_rep(bl), detail::fw_bl_pwl(bl, fw)) + { + } - std::vector intervals() const - { - std::vector intervals_rep = base::intervals(); - std::vector intervals_qty; - intervals_qty.reserve(intervals_rep.size()); - for (const rep& val : intervals_rep) { intervals_qty.push_back(Q(val)); } - return intervals_qty; + template + piecewise_linear_distribution(std::size_t nw, const Q& xmin, const Q& xmax, UnaryOperation fw) : + base(nw, xmin.number(), xmax.number(), [fw](rep val) { return fw(Q(val)); }) + { + } + + template + Q operator()(Generator& g) + { + return Q(base::operator()(g)); + } + + std::vector intervals() const + { + std::vector intervals_rep = base::intervals(); + std::vector intervals_qty; + intervals_qty.reserve(intervals_rep.size()); + for (const rep& val : intervals_rep) { + intervals_qty.push_back(Q(val)); } - - Q min() const { return Q(base::min()); } - Q max() const { return Q(base::max()); } + return intervals_qty; + } + + Q min() const { return Q(base::min()); } + Q max() const { return Q(base::max()); } }; -} // namespace units +} // namespace units diff --git a/src/core/include/units/ratio.h b/src/core/include/units/ratio.h index caf2571f..1e35b47e 100644 --- a/src/core/include/units/ratio.h +++ b/src/core/include/units/ratio.h @@ -30,9 +30,9 @@ #include // IWYU pragma: end_exports +#include #include #include -#include namespace units { @@ -52,7 +52,7 @@ struct ratio { std::intmax_t den; std::intmax_t exp; - constexpr explicit(false) ratio(std::intmax_t n, std::intmax_t d = 1, std::intmax_t e = 0): num(n), den(d), exp(e) + constexpr explicit(false) ratio(std::intmax_t n, std::intmax_t d = 1, std::intmax_t e = 0) : num(n), den(d), exp(e) { gsl_Expects(den != 0); detail::normalize(num, den, exp); @@ -60,16 +60,13 @@ struct ratio { [[nodiscard]] friend constexpr bool operator==(const ratio&, const ratio&) = default; - [[nodiscard]] friend constexpr ratio operator-(const ratio& r) - { - return ratio(-r.num, r.den, r.exp); - } + [[nodiscard]] friend constexpr ratio operator-(const ratio& r) { return ratio(-r.num, r.den, r.exp); } [[nodiscard]] friend constexpr ratio operator+(ratio lhs, ratio rhs) { // First, get the inputs into a common exponent. const auto common_exp = std::min(lhs.exp, rhs.exp); - auto commonify = [common_exp](ratio &r) { + auto commonify = [common_exp](ratio& r) { while (r.exp > common_exp) { r.num *= 10; --r.exp; @@ -86,24 +83,17 @@ struct ratio { const std::intmax_t gcd1 = std::gcd(lhs.num, rhs.den); const std::intmax_t gcd2 = std::gcd(rhs.num, lhs.den); return ratio(detail::safe_multiply(lhs.num / gcd1, rhs.num / gcd2), - detail::safe_multiply(lhs.den / gcd2, rhs.den / gcd1), - lhs.exp + rhs.exp); + detail::safe_multiply(lhs.den / gcd2, rhs.den / gcd1), lhs.exp + rhs.exp); } - [[nodiscard]] friend constexpr ratio operator/(const ratio& lhs, const ratio& rhs) - { - return lhs * inverse(rhs); - } + [[nodiscard]] friend constexpr ratio operator/(const ratio& lhs, const ratio& rhs) { return lhs * inverse(rhs); } }; -[[nodiscard]] constexpr ratio inverse(const ratio& r) -{ - return ratio(r.den, r.num, -r.exp); -} +[[nodiscard]] constexpr ratio inverse(const ratio& r) { return ratio(r.den, r.num, -r.exp); } [[nodiscard]] constexpr bool is_integral(const ratio& r) { - if(r.exp < 0) { + if (r.exp < 0) { return false; } else { return detail::gcdpow(r.num, r.exp, r.den) == r.den; diff --git a/src/core/include/units/reference.h b/src/core/include/units/reference.h index 85e9a18b..cca74b79 100644 --- a/src/core/include/units/reference.h +++ b/src/core/include/units/reference.h @@ -36,24 +36,26 @@ struct reference; namespace detail { template -using reference_multiply_impl = reference::ratio) * (U2::ratio / dimension_unit::ratio) * dimension_unit::ratio>>; +using reference_multiply_impl = + reference::ratio) * (U2::ratio / dimension_unit::ratio) * + dimension_unit::ratio>>; template -using reference_divide_impl = reference::ratio) / (U2::ratio / dimension_unit::ratio) * dimension_unit::ratio>>; +using reference_divide_impl = + reference::ratio) / (U2::ratio / dimension_unit::ratio) * + dimension_unit::ratio>>; } // namespace detail template -using reference_multiply = detail::reference_multiply_impl< - dimension_multiply, - typename R1::dimension, typename R1::unit, typename R2::dimension, typename R2::unit>; +using reference_multiply = + detail::reference_multiply_impl, + typename R1::dimension, typename R1::unit, typename R2::dimension, typename R2::unit>; template -using reference_divide = detail::reference_divide_impl< - dimension_divide, - typename R1::dimension, typename R1::unit, typename R2::dimension, typename R2::unit>; +using reference_divide = + detail::reference_divide_impl, + typename R1::dimension, typename R1::unit, typename R2::dimension, typename R2::unit>; /** * @brief The type for quantity references @@ -62,21 +64,21 @@ using reference_divide = detail::reference_divide_impl< * * @code{.cpp} * namespace length_references { - * + * * inline constexpr auto m = reference{}; * inline constexpr auto km = reference{}; - * + * * } - * + * * namespace references { - * + * * using namespace length_references; - * + * * } * @endcode - * + * * Quantity references simplify quantity creation: - * + * * @code{.cpp} * using namespace units::isq::si::references; * @@ -85,12 +87,12 @@ using reference_divide = detail::reference_divide_impl< * @endcode * * Also, it is allowed to define custom quantity references from existing ones: - * + * * @code{.cpp} * constexpr auto Nm = N * m; * constexpr auto mph = mi / h; * @endcode - * + * * The following syntaxes are not allowed: * `2 / s`, `km * 3`, `s / 4`, `70 * km / h`. */ @@ -103,10 +105,16 @@ struct reference { // Below friend functions are to be found via argument-dependent lookup only template - [[nodiscard]] friend constexpr reference_multiply operator*(reference, R2) { return {}; } + [[nodiscard]] friend constexpr reference_multiply operator*(reference, R2) + { + return {}; + } template - [[nodiscard]] friend constexpr reference_divide operator/(reference, R2) { return {}; } + [[nodiscard]] friend constexpr reference_divide operator/(reference, R2) + { + return {}; + } template [[nodiscard]] friend constexpr Quantity auto operator*(const Rep& lhs, reference) @@ -117,7 +125,10 @@ struct reference { friend void /*Use `q * (1 * r)` rather than `q * r`.*/ operator*(Quantity auto, reference) = delete; template - [[nodiscard]] friend constexpr bool operator==(reference, R2) { return false; } + [[nodiscard]] friend constexpr bool operator==(reference, R2) + { + return false; + } [[nodiscard]] friend constexpr bool operator==(reference, reference) { return true; } }; diff --git a/src/core/include/units/symbol_text.h b/src/core/include/units/symbol_text.h index 3f3466c1..3af267a0 100644 --- a/src/core/include/units/symbol_text.h +++ b/src/core/include/units/symbol_text.h @@ -25,8 +25,8 @@ // IWYU pragma: begin_exports #include #include -#include #include +#include // IWYU pragma: end_exports #include @@ -42,8 +42,7 @@ constexpr void validate_ascii_string([[maybe_unused]] const char (&s)[N + 1]) no { #ifndef NDEBUG if constexpr (N != 0) - for (size_t i = 0; i < N; ++i) - validate_ascii_char(s[i]); + for (size_t i = 0; i < N; ++i) validate_ascii_char(s[i]); #endif } @@ -52,11 +51,11 @@ constexpr void validate_ascii_string([[maybe_unused]] const char (&s)[N + 1]) no /** * @brief A symbol text representation - * + * * This class template is responsible for definition and handling of a symbol text * representation. In the libary it is used to define symbols of units and prefixes. * Each symbol can have two versions: Unicode and ASCI-only. - * + * * @tparam StandardCharT Character type to be used for a Unicode representation * @tparam N The size of a Unicode symbol * @tparam M The size of the ASCII-only symbol @@ -66,12 +65,30 @@ struct basic_symbol_text { basic_fixed_string standard_; basic_fixed_string ascii_; - constexpr basic_symbol_text(char std) noexcept: standard_(std), ascii_(std) { detail::validate_ascii_char(std); } - constexpr basic_symbol_text(StandardCharT std, char a) noexcept: standard_(std), ascii_(a) { detail::validate_ascii_char(a); } - constexpr basic_symbol_text(const char (&std)[N + 1]) noexcept: standard_(std), ascii_(std) { detail::validate_ascii_string(std); } - constexpr basic_symbol_text(const basic_fixed_string& std) noexcept: standard_(std), ascii_(std) { detail::validate_ascii_string(std.data_); } - constexpr basic_symbol_text(const StandardCharT (&std)[N + 1], const char (&a)[M + 1]) noexcept: standard_(std), ascii_(a) { detail::validate_ascii_string(a); } - constexpr basic_symbol_text(const basic_fixed_string& std, const basic_fixed_string& a) noexcept: standard_(std), ascii_(a) { detail::validate_ascii_string(a.data_); } + constexpr basic_symbol_text(char std) noexcept : standard_(std), ascii_(std) { detail::validate_ascii_char(std); } + constexpr basic_symbol_text(StandardCharT std, char a) noexcept : standard_(std), ascii_(a) + { + detail::validate_ascii_char(a); + } + constexpr basic_symbol_text(const char (&std)[N + 1]) noexcept : standard_(std), ascii_(std) + { + detail::validate_ascii_string(std); + } + constexpr basic_symbol_text(const basic_fixed_string& std) noexcept : standard_(std), ascii_(std) + { + detail::validate_ascii_string(std.data_); + } + constexpr basic_symbol_text(const StandardCharT (&std)[N + 1], const char (&a)[M + 1]) noexcept : + standard_(std), ascii_(a) + { + detail::validate_ascii_string(a); + } + constexpr basic_symbol_text(const basic_fixed_string& std, + const basic_fixed_string& a) noexcept : + standard_(std), ascii_(a) + { + detail::validate_ascii_string(a.data_); + } [[nodiscard]] constexpr auto& standard() { return standard_; } [[nodiscard]] constexpr const auto& standard() const { return standard_; } @@ -80,48 +97,47 @@ struct basic_symbol_text { template [[nodiscard]] constexpr friend basic_symbol_text operator+( - const basic_symbol_text& lhs, const basic_symbol_text& rhs) noexcept + const basic_symbol_text& lhs, const basic_symbol_text& rhs) noexcept { - return basic_symbol_text( - lhs.standard() + rhs.standard(), lhs.ascii() + rhs.ascii()); + return basic_symbol_text(lhs.standard() + rhs.standard(), lhs.ascii() + rhs.ascii()); } template [[nodiscard]] constexpr friend basic_symbol_text operator+( - const basic_symbol_text& lhs, const basic_fixed_string& rhs) noexcept + const basic_symbol_text& lhs, const basic_fixed_string& rhs) noexcept { return lhs + basic_symbol_text(rhs); } - + template [[nodiscard]] constexpr friend basic_symbol_text operator+( - const basic_fixed_string& lhs, const basic_symbol_text& rhs) noexcept + const basic_fixed_string& lhs, const basic_symbol_text& rhs) noexcept { return basic_symbol_text(lhs) + rhs; } template [[nodiscard]] constexpr friend basic_symbol_text operator+( - const basic_symbol_text& lhs, const StandardCharT (&rhs)[N2]) noexcept + const basic_symbol_text& lhs, const StandardCharT (&rhs)[N2]) noexcept { return lhs + basic_symbol_text(rhs); } - + template [[nodiscard]] constexpr friend basic_symbol_text operator+( - const StandardCharT (&lhs)[N2], const basic_symbol_text& rhs) noexcept + const StandardCharT (&lhs)[N2], const basic_symbol_text& rhs) noexcept { return basic_symbol_text(lhs) + rhs; } - [[nodiscard]] constexpr friend basic_symbol_text operator+( - const basic_symbol_text& lhs, StandardCharT rhs) noexcept + [[nodiscard]] constexpr friend basic_symbol_text operator+(const basic_symbol_text& lhs, + StandardCharT rhs) noexcept { return lhs + basic_symbol_text(rhs); } - + [[nodiscard]] constexpr friend basic_symbol_text operator+( - StandardCharT lhs, const basic_symbol_text& rhs) noexcept + StandardCharT lhs, const basic_symbol_text& rhs) noexcept { return basic_symbol_text(lhs) + rhs; } @@ -142,7 +158,7 @@ struct basic_symbol_text { } }; -basic_symbol_text(char) -> basic_symbol_text; +basic_symbol_text(char)->basic_symbol_text; template basic_symbol_text(StandardCharT, char) -> basic_symbol_text; @@ -157,7 +173,7 @@ template basic_symbol_text(const StandardCharT (&)[N], const char (&)[M]) -> basic_symbol_text; template -basic_symbol_text(const basic_fixed_string&, - const basic_fixed_string&) -> basic_symbol_text; +basic_symbol_text(const basic_fixed_string&, const basic_fixed_string&) + -> basic_symbol_text; } // namespace units diff --git a/src/core/include/units/unit.h b/src/core/include/units/unit.h index a4a46463..81cec37b 100644 --- a/src/core/include/units/unit.h +++ b/src/core/include/units/unit.h @@ -26,9 +26,9 @@ #include // IWYU pragma: begin_exports -#include +#include #include -#include +#include #include #include // IWYU pragma: end_exports @@ -41,7 +41,7 @@ namespace units { * A unit is an entity defined and adopted by convention, with which any other quantity of * the same kind can be compared to express the ratio of the second quantity to the first * one as a number. - * + * * All units of the same dimension can be convereted between each other. To allow this all of * them are expressed as different ratios of the same one proprietary chosen reference unit * (i.e. all length units are expressed in terms of meter, all mass units are expressed in @@ -162,7 +162,7 @@ struct derived_unit : downcast_dispatch {}; diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h index e314d657..e842cf3e 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/binary_prefixes.h @@ -28,11 +28,11 @@ namespace units::isq::iec80000 { struct binary_prefix : prefix_family {}; -struct kibi : units::prefix {}; -struct mebi : units::prefix {}; -struct gibi : units::prefix {}; -struct tebi : units::prefix {}; -struct pebi : units::prefix {}; +struct kibi : units::prefix {}; +struct mebi : units::prefix {}; +struct gibi : units::prefix {}; +struct tebi : units::prefix {}; +struct pebi : units::prefix {}; struct exbi : units::prefix {}; } // namespace units::isq::iec80000 diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h index d0f595dc..dcb3d805 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/modulation_rate.h @@ -54,19 +54,55 @@ using modulation_rate = quantity; inline namespace literals { -constexpr auto operator"" _q_Bd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_kBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_MBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_GBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_TBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_PBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_EBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_ZBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } -constexpr auto operator"" _q_YBd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return modulation_rate(static_cast(l)); } +constexpr auto operator"" _q_Bd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_kBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_MBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_GBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_TBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_PBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_EBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_ZBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} +constexpr auto operator"" _q_YBd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return modulation_rate(static_cast(l)); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -90,7 +126,7 @@ using namespace modulation_rate_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::iec80000 @@ -98,16 +134,25 @@ using namespace modulation_rate_references; namespace units::aliases::isq::iec80000::inline modulation_rate { -template using Bd = units::isq::iec80000::modulation_rate; -template using kBd = units::isq::iec80000::modulation_rate; -template using MBd = units::isq::iec80000::modulation_rate; -template using GBd = units::isq::iec80000::modulation_rate; -template using TBd = units::isq::iec80000::modulation_rate; -template using PBd = units::isq::iec80000::modulation_rate; -template using EBd = units::isq::iec80000::modulation_rate; -template using ZBd = units::isq::iec80000::modulation_rate; -template using YBd = units::isq::iec80000::modulation_rate; +template +using Bd = units::isq::iec80000::modulation_rate; +template +using kBd = units::isq::iec80000::modulation_rate; +template +using MBd = units::isq::iec80000::modulation_rate; +template +using GBd = units::isq::iec80000::modulation_rate; +template +using TBd = units::isq::iec80000::modulation_rate; +template +using PBd = units::isq::iec80000::modulation_rate; +template +using EBd = units::isq::iec80000::modulation_rate; +template +using ZBd = units::isq::iec80000::modulation_rate; +template +using YBd = units::isq::iec80000::modulation_rate; } // namespace units::aliases::isq::iec80000::inline modulation_rate -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h index 7b1c0a2f..c8ea04f7 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/storage_capacity.h @@ -84,46 +84,163 @@ using storage_capacity = quantity; inline namespace literals { // bits -constexpr auto operator"" _q_bit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_bit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} -constexpr auto operator"" _q_kbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Mbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Gbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Tbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Pbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Ebit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Zbit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Ybit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_kbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Mbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Gbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Tbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Pbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Ebit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Zbit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Ybit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} -constexpr auto operator"" _q_Kibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Mibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Gibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Tibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Pibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_Eibit(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_Kibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Mibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Gibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Tibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Pibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_Eibit(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} // bytes -constexpr auto operator"" _q_B(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_B(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} -constexpr auto operator"" _q_kB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_MB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_GB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_TB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_PB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_EB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_ZB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_YB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_kB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_MB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_GB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_TB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_PB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_EB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_ZB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_YB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} -constexpr auto operator"" _q_KiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_MiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_GiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_TiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -constexpr auto operator"" _q_PiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } -// constexpr auto operator"" _q_EiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return storage_capacity(static_cast(l)); } +constexpr auto operator"" _q_KiB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_MiB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_GiB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_TiB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +constexpr auto operator"" _q_PiB(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return storage_capacity(static_cast(l)); +} +// constexpr auto operator"" _q_EiB(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return +// storage_capacity(static_cast(l)); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -175,7 +292,7 @@ using namespace storage_capacity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::iec80000 @@ -184,43 +301,73 @@ using namespace storage_capacity_references; namespace units::aliases::isq::iec80000::inline storage_capacity { // bits -template using bit = units::isq::iec80000::storage_capacity; +template +using bit = units::isq::iec80000::storage_capacity; -template using kbit = units::isq::iec80000::storage_capacity; -template using Mbit = units::isq::iec80000::storage_capacity; -template using Gbit = units::isq::iec80000::storage_capacity; -template using Tbit = units::isq::iec80000::storage_capacity; -template using Pbit = units::isq::iec80000::storage_capacity; -template using Ebit = units::isq::iec80000::storage_capacity; -template using Zbit = units::isq::iec80000::storage_capacity; -template using Ybit = units::isq::iec80000::storage_capacity; +template +using kbit = units::isq::iec80000::storage_capacity; +template +using Mbit = units::isq::iec80000::storage_capacity; +template +using Gbit = units::isq::iec80000::storage_capacity; +template +using Tbit = units::isq::iec80000::storage_capacity; +template +using Pbit = units::isq::iec80000::storage_capacity; +template +using Ebit = units::isq::iec80000::storage_capacity; +template +using Zbit = units::isq::iec80000::storage_capacity; +template +using Ybit = units::isq::iec80000::storage_capacity; -template using Kibit = units::isq::iec80000::storage_capacity; -template using Mibit = units::isq::iec80000::storage_capacity; -template using Gibit = units::isq::iec80000::storage_capacity; -template using Tibit = units::isq::iec80000::storage_capacity; -template using Pibit = units::isq::iec80000::storage_capacity; -template using Eibit = units::isq::iec80000::storage_capacity; +template +using Kibit = units::isq::iec80000::storage_capacity; +template +using Mibit = units::isq::iec80000::storage_capacity; +template +using Gibit = units::isq::iec80000::storage_capacity; +template +using Tibit = units::isq::iec80000::storage_capacity; +template +using Pibit = units::isq::iec80000::storage_capacity; +template +using Eibit = units::isq::iec80000::storage_capacity; // bytes -template using B = units::isq::iec80000::storage_capacity; +template +using B = units::isq::iec80000::storage_capacity; -template using kB = units::isq::iec80000::storage_capacity; -template using MB = units::isq::iec80000::storage_capacity; -template using GB = units::isq::iec80000::storage_capacity; -template using TB = units::isq::iec80000::storage_capacity; -template using PB = units::isq::iec80000::storage_capacity; -template using EB = units::isq::iec80000::storage_capacity; -template using ZB = units::isq::iec80000::storage_capacity; -template using YB = units::isq::iec80000::storage_capacity; +template +using kB = units::isq::iec80000::storage_capacity; +template +using MB = units::isq::iec80000::storage_capacity; +template +using GB = units::isq::iec80000::storage_capacity; +template +using TB = units::isq::iec80000::storage_capacity; +template +using PB = units::isq::iec80000::storage_capacity; +template +using EB = units::isq::iec80000::storage_capacity; +template +using ZB = units::isq::iec80000::storage_capacity; +template +using YB = units::isq::iec80000::storage_capacity; -template using KiB = units::isq::iec80000::storage_capacity; -template using MiB = units::isq::iec80000::storage_capacity; -template using GiB = units::isq::iec80000::storage_capacity; -template using TiB = units::isq::iec80000::storage_capacity; -template using PiB = units::isq::iec80000::storage_capacity; -// template using EiB = units::isq::iec80000::storage_capacity; +template +using KiB = units::isq::iec80000::storage_capacity; +template +using MiB = units::isq::iec80000::storage_capacity; +template +using GiB = units::isq::iec80000::storage_capacity; +template +using TiB = units::isq::iec80000::storage_capacity; +template +using PiB = units::isq::iec80000::storage_capacity; +// template using EiB = +// units::isq::iec80000::storage_capacity; } // namespace units::aliases::isq::iec80000::inline storage_capacity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h index 15b4fa18..3c17f62d 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/traffic_intensity.h @@ -47,11 +47,15 @@ using traffic_intensity = quantity; inline namespace literals { -constexpr auto operator"" _q_E(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return traffic_intensity(static_cast(l)); } +constexpr auto operator"" _q_E(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return traffic_intensity(static_cast(l)); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace traffic_intensity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::iec80000 @@ -75,8 +79,9 @@ using namespace traffic_intensity_references; namespace units::aliases::isq::iec80000::inline traffic_intensity { -template using E = units::isq::iec80000::traffic_intensity; +template +using E = units::isq::iec80000::traffic_intensity; } // namespace units::aliases::isq::iec80000::inline traffic_intensity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h index ac081b86..bd2bb20c 100644 --- a/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h +++ b/src/systems/isq-iec80000/include/units/isq/iec80000/transfer_rate.h @@ -35,7 +35,9 @@ namespace units::isq::iec80000 { struct byte_per_second : unit {}; -struct dim_transfer_rate : derived_dimension, exponent> {}; +struct dim_transfer_rate : + derived_dimension, + exponent> {}; struct kilobyte_per_second : derived_unit {}; struct megabyte_per_second : derived_unit {}; @@ -56,19 +58,55 @@ using transfer_rate = quantity; inline namespace literals { -constexpr auto operator"" _q_B_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_kB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_MB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_GB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_TB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_PB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_EB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_ZB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } -constexpr auto operator"" _q_YB_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return transfer_rate(static_cast(l)); } +constexpr auto operator"" _q_B_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_kB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_MB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_GB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_TB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_PB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_EB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_ZB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} +constexpr auto operator"" _q_YB_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return transfer_rate(static_cast(l)); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::iec80000 @@ -76,16 +114,25 @@ constexpr auto operator"" _q_YB_per_s(unsigned long long l) { gsl_ExpectsAudit(s namespace units::aliases::isq::iec80000::inline transfer_rate { -template using B_per_s = units::isq::iec80000::transfer_rate; -template using kB_per_s = units::isq::iec80000::transfer_rate; -template using MB_per_s = units::isq::iec80000::transfer_rate; -template using GB_per_s = units::isq::iec80000::transfer_rate; -template using TB_per_s = units::isq::iec80000::transfer_rate; -template using PB_per_s = units::isq::iec80000::transfer_rate; -template using EB_per_s = units::isq::iec80000::transfer_rate; -template using ZB_per_s = units::isq::iec80000::transfer_rate; -template using YB_per_s = units::isq::iec80000::transfer_rate; +template +using B_per_s = units::isq::iec80000::transfer_rate; +template +using kB_per_s = units::isq::iec80000::transfer_rate; +template +using MB_per_s = units::isq::iec80000::transfer_rate; +template +using GB_per_s = units::isq::iec80000::transfer_rate; +template +using TB_per_s = units::isq::iec80000::transfer_rate; +template +using PB_per_s = units::isq::iec80000::transfer_rate; +template +using EB_per_s = units::isq::iec80000::transfer_rate; +template +using ZB_per_s = units::isq::iec80000::transfer_rate; +template +using YB_per_s = units::isq::iec80000::transfer_rate; } // namespace units::aliases::isq::iec80000::inline transfer_rate -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/acceleration.h b/src/systems/isq-natural/include/units/isq/natural/acceleration.h index 35f765eb..4b6828e1 100644 --- a/src/systems/isq-natural/include/units/isq/natural/acceleration.h +++ b/src/systems/isq-natural/include/units/isq/natural/acceleration.h @@ -48,13 +48,13 @@ inline constexpr auto GeV = reference{}; } // namespace acceleration_references -namespace references { +namespace references { using namespace acceleration_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -62,8 +62,9 @@ using namespace acceleration_references; namespace units::aliases::isq::natural::inline acceleration { -template using GeV = units::isq::natural::acceleration; +template +using GeV = units::isq::natural::acceleration; } // namespace units::aliases::isq::natural::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/energy.h b/src/systems/isq-natural/include/units/isq/natural/energy.h index 9924af00..84587a0a 100644 --- a/src/systems/isq-natural/include/units/isq/natural/energy.h +++ b/src/systems/isq-natural/include/units/isq/natural/energy.h @@ -48,13 +48,13 @@ inline constexpr auto GeV = reference{}; } // namespace energy_references -namespace references { +namespace references { using namespace energy_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -62,8 +62,9 @@ using namespace energy_references; namespace units::aliases::isq::natural::inline energy { -template using GeV = units::isq::natural::energy; +template +using GeV = units::isq::natural::energy; } // namespace units::aliases::isq::natural::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/force.h b/src/systems/isq-natural/include/units/isq/natural/force.h index f1e08f0c..26921dfc 100644 --- a/src/systems/isq-natural/include/units/isq/natural/force.h +++ b/src/systems/isq-natural/include/units/isq/natural/force.h @@ -48,13 +48,13 @@ inline constexpr auto GeV2 = reference{}; } // namespace force_references -namespace references { +namespace references { using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -62,8 +62,9 @@ using namespace force_references; namespace units::aliases::isq::natural::inline force { -template using GeV2 = units::isq::natural::force; +template +using GeV2 = units::isq::natural::force; } // namespace units::aliases::isq::natural::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/length.h b/src/systems/isq-natural/include/units/isq/natural/length.h index b7c7aa41..7174a525 100644 --- a/src/systems/isq-natural/include/units/isq/natural/length.h +++ b/src/systems/isq-natural/include/units/isq/natural/length.h @@ -45,13 +45,13 @@ inline constexpr auto inv_GeV = reference } // namespace length_references -namespace references { +namespace references { using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -59,8 +59,9 @@ using namespace length_references; namespace units::aliases::isq::natural::inline length { -template using inv_GeV = units::isq::natural::length; +template +using inv_GeV = units::isq::natural::length; } // namespace units::aliases::isq::natural::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/mass.h b/src/systems/isq-natural/include/units/isq/natural/mass.h index 55d8a24f..d9ff98de 100644 --- a/src/systems/isq-natural/include/units/isq/natural/mass.h +++ b/src/systems/isq-natural/include/units/isq/natural/mass.h @@ -45,13 +45,13 @@ inline constexpr auto GeV = reference{}; } // namespace mass_references -namespace references { +namespace references { using namespace mass_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -59,8 +59,9 @@ using namespace mass_references; namespace units::aliases::isq::natural::inline mass { -template using GeV = units::isq::natural::mass; +template +using GeV = units::isq::natural::mass; } // namespace units::aliases::isq::natural::inline mass -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/momentum.h b/src/systems/isq-natural/include/units/isq/natural/momentum.h index 66e2fe96..32f633d5 100644 --- a/src/systems/isq-natural/include/units/isq/natural/momentum.h +++ b/src/systems/isq-natural/include/units/isq/natural/momentum.h @@ -48,13 +48,13 @@ inline constexpr auto GeV = reference{}; } // namespace momentum_references -namespace references { +namespace references { using namespace momentum_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -62,8 +62,9 @@ using namespace momentum_references; namespace units::aliases::isq::natural::inline momentum { -template using GeV = units::isq::natural::momentum; +template +using GeV = units::isq::natural::momentum; } // namespace units::aliases::isq::natural::inline momentum -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/time.h b/src/systems/isq-natural/include/units/isq/natural/time.h index ea903166..fc82e5ea 100644 --- a/src/systems/isq-natural/include/units/isq/natural/time.h +++ b/src/systems/isq-natural/include/units/isq/natural/time.h @@ -45,13 +45,13 @@ inline constexpr auto inv_GeV = reference{} } // namespace time_references -namespace references { +namespace references { using namespace time_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::natural @@ -59,8 +59,9 @@ using namespace time_references; namespace units::aliases::isq::natural::inline time { -template using inv_GeV = units::isq::natural::time; +template +using inv_GeV = units::isq::natural::time; } // namespace units::aliases::isq::natural::inline time -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/isq-natural/include/units/isq/natural/units.h b/src/systems/isq-natural/include/units/isq/natural/units.h index f3fcc54b..1d64e28b 100644 --- a/src/systems/isq-natural/include/units/isq/natural/units.h +++ b/src/systems/isq-natural/include/units/isq/natural/units.h @@ -33,7 +33,8 @@ namespace units::isq::natural { struct electronvolt : named_unit {}; struct gigaelectronvolt : prefixed_unit {}; -struct inverted_gigaelectronvolt : named_unit {}; +struct inverted_gigaelectronvolt : + named_unit {}; struct square_gigaelectronvolt : named_unit {}; // NOTE: eV as a base unit with no relation to joule prevents us from going back diff --git a/src/systems/isq/include/units/isq/dimensions/angular_velocity.h b/src/systems/isq/include/units/isq/dimensions/angular_velocity.h index 1554dced..e2ae4b69 100644 --- a/src/systems/isq/include/units/isq/dimensions/angular_velocity.h +++ b/src/systems/isq/include/units/isq/dimensions/angular_velocity.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { @@ -34,7 +34,7 @@ struct dim_angular_velocity; template A, DimensionOfT T> struct dim_angular_velocity : derived_dimension, exponent> {}; -template +template concept AngularVelocity = QuantityOfT; } // namespace units::isq diff --git a/src/systems/isq/include/units/isq/dimensions/catalytic_activity.h b/src/systems/isq/include/units/isq/dimensions/catalytic_activity.h index 8a07c879..f0d67250 100644 --- a/src/systems/isq/include/units/isq/dimensions/catalytic_activity.h +++ b/src/systems/isq/include/units/isq/dimensions/catalytic_activity.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/concentration.h b/src/systems/isq/include/units/isq/dimensions/concentration.h index f8592d98..c5181d44 100644 --- a/src/systems/isq/include/units/isq/dimensions/concentration.h +++ b/src/systems/isq/include/units/isq/dimensions/concentration.h @@ -23,8 +23,8 @@ #pragma once #include -#include #include +#include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/force.h b/src/systems/isq/include/units/isq/dimensions/force.h index c8f11d75..20dc9540 100644 --- a/src/systems/isq/include/units/isq/dimensions/force.h +++ b/src/systems/isq/include/units/isq/dimensions/force.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/heat_capacity.h b/src/systems/isq/include/units/isq/dimensions/heat_capacity.h index 6d96fb40..d4c3e0d4 100644 --- a/src/systems/isq/include/units/isq/dimensions/heat_capacity.h +++ b/src/systems/isq/include/units/isq/dimensions/heat_capacity.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include #include #include diff --git a/src/systems/isq/include/units/isq/dimensions/luminance.h b/src/systems/isq/include/units/isq/dimensions/luminance.h index 5e665d58..c5215828 100644 --- a/src/systems/isq/include/units/isq/dimensions/luminance.h +++ b/src/systems/isq/include/units/isq/dimensions/luminance.h @@ -23,8 +23,8 @@ #pragma once #include -#include #include +#include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/magnetic_flux.h b/src/systems/isq/include/units/isq/dimensions/magnetic_flux.h index 67fe78e2..d0f2dab5 100644 --- a/src/systems/isq/include/units/isq/dimensions/magnetic_flux.h +++ b/src/systems/isq/include/units/isq/dimensions/magnetic_flux.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/magnetic_induction.h b/src/systems/isq/include/units/isq/dimensions/magnetic_induction.h index 023fa2fa..b7b54c0b 100644 --- a/src/systems/isq/include/units/isq/dimensions/magnetic_induction.h +++ b/src/systems/isq/include/units/isq/dimensions/magnetic_induction.h @@ -29,11 +29,12 @@ namespace units::isq { -template +template struct dim_magnetic_induction; -template V, DimensionOfT T, DimensionOfT L> -struct dim_magnetic_induction : derived_dimension, exponent, exponent> {}; +template V, DimensionOfT T, DimensionOfT L> +struct dim_magnetic_induction : + derived_dimension, exponent, exponent> {}; template concept MagneticInduction = QuantityOfT; diff --git a/src/systems/isq/include/units/isq/dimensions/molar_energy.h b/src/systems/isq/include/units/isq/dimensions/molar_energy.h index a60bb3df..a8b152b0 100644 --- a/src/systems/isq/include/units/isq/dimensions/molar_energy.h +++ b/src/systems/isq/include/units/isq/dimensions/molar_energy.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/permittivity.h b/src/systems/isq/include/units/isq/dimensions/permittivity.h index 78b0bb44..70601e6d 100644 --- a/src/systems/isq/include/units/isq/dimensions/permittivity.h +++ b/src/systems/isq/include/units/isq/dimensions/permittivity.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/pressure.h b/src/systems/isq/include/units/isq/dimensions/pressure.h index 48858a28..47578401 100644 --- a/src/systems/isq/include/units/isq/dimensions/pressure.h +++ b/src/systems/isq/include/units/isq/dimensions/pressure.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/isq/include/units/isq/dimensions/resistance.h b/src/systems/isq/include/units/isq/dimensions/resistance.h index 3af040cd..e9d8f9b5 100644 --- a/src/systems/isq/include/units/isq/dimensions/resistance.h +++ b/src/systems/isq/include/units/isq/dimensions/resistance.h @@ -28,11 +28,11 @@ namespace units::isq { -template +template struct dim_resistance; -template V, DimensionOfT C> -struct dim_resistance : derived_dimension, exponent> {}; +template V, DimensionOfT C> +struct dim_resistance : derived_dimension, exponent> {}; template concept Resistance = QuantityOfT; diff --git a/src/systems/isq/include/units/isq/dimensions/thermal_conductivity.h b/src/systems/isq/include/units/isq/dimensions/thermal_conductivity.h index f7da8411..1fe804d5 100644 --- a/src/systems/isq/include/units/isq/dimensions/thermal_conductivity.h +++ b/src/systems/isq/include/units/isq/dimensions/thermal_conductivity.h @@ -32,8 +32,10 @@ namespace units::isq { template struct dim_thermal_conductivity; -template P, DimensionOfT L, DimensionOfT T> -struct dim_thermal_conductivity : derived_dimension, exponent, exponent> {}; +template P, DimensionOfT L, + DimensionOfT T> +struct dim_thermal_conductivity : + derived_dimension, exponent, exponent> {}; template concept ThermalConductivity = QuantityOfT; diff --git a/src/systems/isq/include/units/isq/dimensions/torque.h b/src/systems/isq/include/units/isq/dimensions/torque.h index 3a0c3697..e134318e 100644 --- a/src/systems/isq/include/units/isq/dimensions/torque.h +++ b/src/systems/isq/include/units/isq/dimensions/torque.h @@ -22,8 +22,8 @@ #pragma once -#include #include +#include #include namespace units::isq { diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h b/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h index 26c5aea2..53d56784 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/acceleration.h @@ -45,12 +45,16 @@ using acceleration = quantity; inline namespace literals { // Gal -constexpr auto operator"" _q_Gal(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return acceleration(static_cast(l)); } +constexpr auto operator"" _q_Gal(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return acceleration(static_cast(l)); +} constexpr auto operator"" _q_Gal(long double l) { return acceleration(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -66,7 +70,7 @@ using namespace acceleration_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -74,8 +78,9 @@ using namespace acceleration_references; namespace units::aliases::isq::si::cgs::inline acceleration { -template using Gal = units::isq::si::cgs::acceleration; +template +using Gal = units::isq::si::cgs::acceleration; } // namespace units::aliases::isq::si::cgs::inline acceleration -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/area.h b/src/systems/si-cgs/include/units/isq/si/cgs/area.h index ceb567ae..ca3e14da 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/area.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/area.h @@ -47,12 +47,16 @@ using area = quantity; inline namespace literals { // cm2 -constexpr auto operator"" _q_cm2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return area(static_cast(l)); } +constexpr auto operator"" _q_cm2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return area(static_cast(l)); +} constexpr auto operator"" _q_cm2(long double l) { return area(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -68,7 +72,7 @@ using namespace area_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -76,8 +80,9 @@ using namespace area_references; namespace units::aliases::isq::si::cgs::inline area { -template using cm2 = units::isq::si::cgs::area; +template +using cm2 = units::isq::si::cgs::area; } // namespace units::aliases::isq::si::cgs::inline area -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/cgs.h b/src/systems/si-cgs/include/units/isq/si/cgs/cgs.h index 4a74121e..26453d23 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/cgs.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/cgs.h @@ -23,15 +23,14 @@ #pragma once // IWYU pragma: begin_exports -#include -#include -#include - #include #include #include #include +#include +#include #include #include #include +#include // IWYU pragma: end_exports diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/energy.h b/src/systems/si-cgs/include/units/isq/si/cgs/energy.h index 7c9852f1..d6e0c16b 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/energy.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/energy.h @@ -47,12 +47,16 @@ using energy = quantity; inline namespace literals { // erg -constexpr auto operator"" _q_erg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_erg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_erg(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -68,7 +72,7 @@ using namespace energy_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -76,8 +80,9 @@ using namespace energy_references; namespace units::aliases::isq::si::cgs::inline energy { -template using erg = units::isq::si::cgs::energy; +template +using erg = units::isq::si::cgs::energy; } // namespace units::aliases::isq::si::cgs::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/force.h b/src/systems/si-cgs/include/units/isq/si/cgs/force.h index 85a0edf2..e00f5a0d 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/force.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/force.h @@ -48,12 +48,16 @@ using force = quantity; inline namespace literals { // dyn -constexpr auto operator"" _q_dyn(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return force(static_cast(l)); } +constexpr auto operator"" _q_dyn(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return force(static_cast(l)); +} constexpr auto operator"" _q_dyn(long double l) { return force(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -69,7 +73,7 @@ using namespace force_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -77,8 +81,9 @@ using namespace force_references; namespace units::aliases::isq::si::cgs::inline force { -template using dyn = units::isq::si::cgs::force; +template +using dyn = units::isq::si::cgs::force; } // namespace units::aliases::isq::si::cgs::inline force -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/length.h b/src/systems/si-cgs/include/units/isq/si/cgs/length.h index 75fd8dd1..52e8dc96 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/length.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/length.h @@ -46,12 +46,16 @@ using length = quantity; inline namespace literals { // cm -constexpr auto operator"" _q_cm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_cm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_cm(long double l) { return length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -75,8 +79,9 @@ using namespace length_references; namespace units::aliases::isq::si::cgs::inline length { -template using cm = units::isq::si::cgs::length; +template +using cm = units::isq::si::cgs::length; } // namespace units::aliases::isq::si::cgs::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/mass.h b/src/systems/si-cgs/include/units/isq/si/cgs/mass.h index e2a93653..725447a0 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/mass.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/mass.h @@ -46,12 +46,16 @@ using mass = quantity; inline namespace literals { // g -constexpr auto operator"" _q_g(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_g(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_g(long double l) { return mass(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -67,7 +71,7 @@ using namespace mass_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -75,8 +79,9 @@ using namespace mass_references; namespace units::aliases::isq::si::cgs::inline mass { -template using g = units::isq::si::cgs::mass; +template +using g = units::isq::si::cgs::mass; } // namespace units::aliases::isq::si::cgs::inline mass -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/power.h b/src/systems/si-cgs/include/units/isq/si/cgs/power.h index 1e1844e2..1ac322f6 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/power.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/power.h @@ -46,12 +46,16 @@ using power = quantity; inline namespace literals { // erg/s -constexpr auto operator"" _q_erg_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_erg_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_erg_per_s(long double l) { return power(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::cgs @@ -59,8 +63,9 @@ constexpr auto operator"" _q_erg_per_s(long double l) { return power using erg_per_s = units::isq::si::cgs::power; +template +using erg_per_s = units::isq::si::cgs::power; } // namespace units::aliases::isq::si::cgs::inline power -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h b/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h index cae347e9..5d4f89ea 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/pressure.h @@ -48,12 +48,16 @@ using pressure = quantity; inline namespace literals { // Ba -constexpr auto operator"" _q_Ba(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return pressure(static_cast(l)); } +constexpr auto operator"" _q_Ba(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return pressure(static_cast(l)); +} constexpr auto operator"" _q_Ba(long double l) { return pressure(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -69,7 +73,7 @@ using namespace pressure_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -77,8 +81,9 @@ using namespace pressure_references; namespace units::aliases::isq::si::cgs::inline pressure { -template using Ba = units::isq::si::cgs::pressure; +template +using Ba = units::isq::si::cgs::pressure; } // namespace units::aliases::isq::si::cgs::inline pressure -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/speed.h b/src/systems/si-cgs/include/units/isq/si/cgs/speed.h index 6d2f979d..6cdc4a7d 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/speed.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/speed.h @@ -45,12 +45,16 @@ using speed = quantity; inline namespace literals { // cm/s -constexpr auto operator"" _q_cm_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_cm_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_cm_per_s(long double l) { return speed(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::cgs @@ -58,8 +62,9 @@ constexpr auto operator"" _q_cm_per_s(long double l) { return speed using cm_per_s = units::isq::si::cgs::speed; +template +using cm_per_s = units::isq::si::cgs::speed; } // namespace units::aliases::isq::si::cgs::inline speed -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-cgs/include/units/isq/si/cgs/time.h b/src/systems/si-cgs/include/units/isq/si/cgs/time.h index f721c5b7..e84ae05c 100644 --- a/src/systems/si-cgs/include/units/isq/si/cgs/time.h +++ b/src/systems/si-cgs/include/units/isq/si/cgs/time.h @@ -45,7 +45,7 @@ using si::literals::operator"" _q_s; } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -61,7 +61,7 @@ using namespace time_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::cgs @@ -73,4 +73,4 @@ using namespace units::aliases::isq::si::time; } // namespace units::aliases::isq::si::cgs::inline time -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/length.h b/src/systems/si-fps/include/units/isq/si/fps/length.h index e41387ae..c037afe1 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/length.h +++ b/src/systems/si-fps/include/units/isq/si/fps/length.h @@ -41,8 +41,8 @@ struct inch : named_scaled_unit {}; // thousandth of an inch struct thousandth : named_scaled_unit {}; -struct thou : alias_unit{}; -struct mil : alias_unit{}; +struct thou : alias_unit {}; +struct mil : alias_unit {}; struct yard : named_scaled_unit {}; @@ -64,43 +64,79 @@ using length = quantity; inline namespace literals { // Thousandth -constexpr auto operator"" _q_thou(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_thou(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_thou(long double l) { return length(l); } -constexpr auto operator"" _q_mil(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_mil(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_mil(long double l) { return length(l); } // Inch -constexpr auto operator"" _q_in(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_in(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_in(long double l) { return length(l); } // Foot -constexpr auto operator"" _q_ft(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_ft(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_ft(long double l) { return length(l); } // Yard -constexpr auto operator"" _q_yd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_yd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_yd(long double l) { return length(l); } // Fathom -constexpr auto operator"" _q_ftm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_ftm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_ftm(long double l) { return length(l); } // Kiloyard -constexpr auto operator"" _q_kyd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_kyd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_kyd(long double l) { return length(l); } // Mile -constexpr auto operator"" _q_mile(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_mile(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_mile(long double l) { return length(l); } // Nautical mile -constexpr auto operator"" _q_naut_mi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_naut_mi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_naut_mi(long double l) { return length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -125,7 +161,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -133,17 +169,26 @@ using namespace length_references; namespace units::aliases::isq::si::fps::inline length { -template using thou = units::isq::si::fps::length; -template using mil = thou; +template +using thou = units::isq::si::fps::length; +template +using mil = thou; -template using in = units::isq::si::fps::length; -template using ft = units::isq::si::fps::length; -template using yd = units::isq::si::fps::length; -template using ftm = units::isq::si::fps::length; -template using kyd = units::isq::si::fps::length; -template using mile = units::isq::si::fps::length; -template using naut_mi = units::isq::si::fps::length; +template +using in = units::isq::si::fps::length; +template +using ft = units::isq::si::fps::length; +template +using yd = units::isq::si::fps::length; +template +using ftm = units::isq::si::fps::length; +template +using kyd = units::isq::si::fps::length; +template +using mile = units::isq::si::fps::length; +template +using naut_mi = units::isq::si::fps::length; } // namespace units::aliases::isq::si::fps::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/mass.h b/src/systems/si-fps/include/units/isq/si/fps/mass.h index cbf50513..559593d0 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/mass.h +++ b/src/systems/si-fps/include/units/isq/si/fps/mass.h @@ -42,65 +42,101 @@ struct dim_mass : isq::dim_mass {}; template U, Representation Rep = double> using mass = quantity; -struct grain : named_scaled_unit{}; +struct grain : named_scaled_unit {}; -struct dram : named_scaled_unit{}; +struct dram : named_scaled_unit {}; -struct ounce : named_scaled_unit{}; +struct ounce : named_scaled_unit {}; -struct stone : named_scaled_unit{}; +struct stone : named_scaled_unit {}; -struct quarter : named_scaled_unit{}; +struct quarter : named_scaled_unit {}; -struct hundredweight : named_scaled_unit{}; +struct hundredweight : named_scaled_unit {}; -struct short_ton : named_scaled_unit{}; +struct short_ton : named_scaled_unit {}; -struct long_ton : named_scaled_unit{}; +struct long_ton : named_scaled_unit {}; #ifndef UNITS_NO_LITERALS inline namespace literals { // Grain -constexpr auto operator"" _q_gr(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_gr(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_gr(long double l) { return mass(l); } // Dram -constexpr auto operator"" _q_dr(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_dr(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_dr(long double l) { return mass(l); } // Ounce -constexpr auto operator"" _q_oz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_oz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_oz(long double l) { return mass(l); } // Pound -constexpr auto operator"" _q_lb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_lb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_lb(long double l) { return mass(l); } // Stone -constexpr auto operator"" _q_st(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_st(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_st(long double l) { return mass(l); } // Quarter -constexpr auto operator"" _q_qr(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_qr(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_qr(long double l) { return mass(l); } // Hundredweight -constexpr auto operator"" _q_cwt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_cwt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_cwt(long double l) { return mass(l); } // Short ton -constexpr auto operator"" _q_ston(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ston(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ston(long double l) { return mass(l); } // Long Ton -constexpr auto operator"" _q_lton(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_lton(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_lton(long double l) { return mass(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -124,7 +160,7 @@ using namespace mass_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -132,16 +168,25 @@ using namespace mass_references; namespace units::aliases::isq::si::fps::inline mass { -template using gr = units::isq::si::fps::mass; -template using dr = units::isq::si::fps::mass; -template using oz = units::isq::si::fps::mass; -template using lb = units::isq::si::fps::mass; -template using st = units::isq::si::fps::mass; -template using qr = units::isq::si::fps::mass; -template using cwt = units::isq::si::fps::mass; -template using ston = units::isq::si::fps::mass; -template using lton = units::isq::si::fps::mass; +template +using gr = units::isq::si::fps::mass; +template +using dr = units::isq::si::fps::mass; +template +using oz = units::isq::si::fps::mass; +template +using lb = units::isq::si::fps::mass; +template +using st = units::isq::si::fps::mass; +template +using qr = units::isq::si::fps::mass; +template +using cwt = units::isq::si::fps::mass; +template +using ston = units::isq::si::fps::mass; +template +using lton = units::isq::si::fps::mass; } // namespace units::aliases::isq::si::fps::inline mass -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/power.h b/src/systems/si-fps/include/units/isq/si/fps/power.h index d8cb69fe..d48d1f31 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/power.h +++ b/src/systems/si-fps/include/units/isq/si/fps/power.h @@ -51,20 +51,32 @@ using power = quantity; inline namespace literals { // foot pound force per second -constexpr auto operator"" _q_ft_pdl_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_ft_pdl_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_ft_pdl_per_s(long double l) { return power(l); } // foot pound force per second -constexpr auto operator"" _q_ft_lbf_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_ft_lbf_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_ft_lbf_per_s(long double l) { return power(l); } // horse power -constexpr auto operator"" _q_hp(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_hp(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_hp(long double l) { return power(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -80,7 +92,7 @@ using namespace power_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -88,10 +100,13 @@ using namespace power_references; namespace units::aliases::isq::si::fps::inline power { -template using ft_pdl_per_s = units::isq::si::fps::power; -template using ft_lbf_per_s = units::isq::si::fps::power; -template using hp = units::isq::si::fps::power; +template +using ft_pdl_per_s = units::isq::si::fps::power; +template +using ft_lbf_per_s = units::isq::si::fps::power; +template +using hp = units::isq::si::fps::power; } // namespace units::aliases::isq::si::fps::inline power -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/time.h b/src/systems/si-fps/include/units/isq/si/fps/time.h index 81d3793f..6bf892b8 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/time.h +++ b/src/systems/si-fps/include/units/isq/si/fps/time.h @@ -34,9 +34,9 @@ namespace units::isq::si::fps { -using si::second; -using si::minute; using si::hour; +using si::minute; +using si::second; using si::dim_time; using si::time; @@ -49,7 +49,7 @@ using si::literals::operator"" _q_s; } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -65,7 +65,7 @@ using namespace time_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -77,4 +77,4 @@ using namespace units::aliases::isq::si::time; } // namespace units::aliases::isq::si::fps::inline time -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-fps/include/units/isq/si/fps/volume.h b/src/systems/si-fps/include/units/isq/si/fps/volume.h index 0f809bb6..a461790c 100644 --- a/src/systems/si-fps/include/units/isq/si/fps/volume.h +++ b/src/systems/si-fps/include/units/isq/si/fps/volume.h @@ -47,16 +47,24 @@ using volume = quantity; inline namespace literals { // ft3 -constexpr auto operator"" _q_ft3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_ft3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_ft3(long double l) { return volume(l); } // yd3 -constexpr auto operator"" _q_yd3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_yd3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_yd3(long double l) { return volume(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -73,7 +81,7 @@ using namespace volume_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::fps @@ -81,9 +89,11 @@ using namespace volume_references; namespace units::aliases::isq::si::fps::inline volume { -template using ft3 = units::isq::si::fps::volume; -template using yd3 = units::isq::si::fps::volume; +template +using ft3 = units::isq::si::fps::volume; +template +using yd3 = units::isq::si::fps::volume; } // namespace units::aliases::isq::si::fps::inline volume -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-hep/include/units/isq/si/hep/energy.h b/src/systems/si-hep/include/units/isq/si/hep/energy.h index 25c42a8d..dd76f8fe 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/energy.h +++ b/src/systems/si-hep/include/units/isq/si/hep/energy.h @@ -34,9 +34,9 @@ namespace units::isq::si::hep { using units::isq::si::electronvolt; -struct yeV : prefixed_unit {}; // N.B. very rarely used -struct zeV : prefixed_unit {}; // N.B. very rarely used -struct aeV : prefixed_unit {}; // N.B. very rarely used +struct yeV : prefixed_unit {}; // N.B. very rarely used +struct zeV : prefixed_unit {}; // N.B. very rarely used +struct aeV : prefixed_unit {}; // N.B. very rarely used struct feV : prefixed_unit {}; struct peV : prefixed_unit {}; struct neV : prefixed_unit {}; @@ -48,9 +48,9 @@ struct MeV : prefixed_unit {}; using GeV = gigaelectronvolt; struct TeV : prefixed_unit {}; struct PeV : prefixed_unit {}; -struct EeV : prefixed_unit {}; // N.B. very rarely used -struct ZeV : prefixed_unit {}; // N.B. very rarely used -struct YeV : prefixed_unit {}; // N.B. very rarely used +struct EeV : prefixed_unit {}; // N.B. very rarely used +struct ZeV : prefixed_unit {}; // N.B. very rarely used +struct YeV : prefixed_unit {}; // N.B. very rarely used template U, Representation Rep = double> using energy = quantity; @@ -59,39 +59,95 @@ using energy = quantity; inline namespace literals { -constexpr auto operator"" _q_feV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_feV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_feV(long double l) { return energy(l); } -constexpr auto operator"" _q_peV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_peV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_peV(long double l) { return energy(l); } -constexpr auto operator"" _q_neV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_neV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_neV(long double l) { return energy(l); } -constexpr auto operator"" _q_ueV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ueV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ueV(long double l) { return energy(l); } -constexpr auto operator"" _q_meV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_meV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_meV(long double l) { return energy(l); } -constexpr auto operator"" _q_eV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_eV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_eV(long double l) { return energy(l); } -constexpr auto operator"" _q_keV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_keV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_keV(long double l) { return energy(l); } -constexpr auto operator"" _q_MeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_MeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_MeV(long double l) { return energy(l); } -constexpr auto operator"" _q_GeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_GeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_GeV(long double l) { return energy(l); } -constexpr auto operator"" _q_TeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_TeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_TeV(long double l) { return energy(l); } -constexpr auto operator"" _q_PeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_PeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_PeV(long double l) { return energy(l); } -constexpr auto operator"" _q_EeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_EeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_EeV(long double l) { return energy(l); } -constexpr auto operator"" _q_ZeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_ZeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_ZeV(long double l) { return energy(l); } -constexpr auto operator"" _q_YeV(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy(static_cast(l)); } +constexpr auto operator"" _q_YeV(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy(static_cast(l)); +} constexpr auto operator"" _q_YeV(long double l) { return energy(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -107,7 +163,7 @@ using namespace energy_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::hep @@ -115,26 +171,43 @@ using namespace energy_references; namespace units::aliases::isq::si::hep::inline energy { -template using yeV = units::isq::si::hep::energy; -template using zeV = units::isq::si::hep::energy; -template using aeV = units::isq::si::hep::energy; -template using feV = units::isq::si::hep::energy; -template using peV = units::isq::si::hep::energy; -template using neV = units::isq::si::hep::energy; -template using ueV = units::isq::si::hep::energy; -template using meV = units::isq::si::hep::energy; +template +using yeV = units::isq::si::hep::energy; +template +using zeV = units::isq::si::hep::energy; +template +using aeV = units::isq::si::hep::energy; +template +using feV = units::isq::si::hep::energy; +template +using peV = units::isq::si::hep::energy; +template +using neV = units::isq::si::hep::energy; +template +using ueV = units::isq::si::hep::energy; +template +using meV = units::isq::si::hep::energy; -template using eV = units::isq::si::hep::energy; +template +using eV = units::isq::si::hep::energy; -template using keV = units::isq::si::hep::energy; -template using MeV = units::isq::si::hep::energy; -template using GeV = units::isq::si::hep::energy; -template using TeV = units::isq::si::hep::energy; -template using PeV = units::isq::si::hep::energy; -template using EeV = units::isq::si::hep::energy; -template using ZeV = units::isq::si::hep::energy; -template using YeV = units::isq::si::hep::energy; +template +using keV = units::isq::si::hep::energy; +template +using MeV = units::isq::si::hep::energy; +template +using GeV = units::isq::si::hep::energy; +template +using TeV = units::isq::si::hep::energy; +template +using PeV = units::isq::si::hep::energy; +template +using EeV = units::isq::si::hep::energy; +template +using ZeV = units::isq::si::hep::energy; +template +using YeV = units::isq::si::hep::energy; } // namespace units::aliases::isq::si::hep::inline energy -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-hep/include/units/isq/si/hep/mass.h b/src/systems/si-hep/include/units/isq/si/hep/mass.h index 237d2d74..2f617544 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/mass.h +++ b/src/systems/si-hep/include/units/isq/si/hep/mass.h @@ -34,22 +34,29 @@ namespace units::isq::si::hep { -struct eV_per_c2 : named_scaled_unit {}; +struct eV_per_c2 : + named_scaled_unit {}; struct feV_per_c2 : prefixed_unit {}; struct peV_per_c2 : prefixed_unit {}; struct neV_per_c2 : prefixed_unit {}; struct ueV_per_c2 : prefixed_unit {}; -struct meV_per_c2 : prefixed_unit {}; // approximate mass of an electron/positron (0.511 MeV/c2) +struct meV_per_c2 : + prefixed_unit {}; // approximate mass of an electron/positron (0.511 MeV/c2) struct keV_per_c2 : prefixed_unit {}; struct MeV_per_c2 : prefixed_unit {}; -struct GeV_per_c2 : prefixed_unit {}; // approximate mass of a proton (0.938 GeV/c2) or neutron +struct GeV_per_c2 : + prefixed_unit {}; // approximate mass of a proton (0.938 GeV/c2) or neutron struct TeV_per_c2 : prefixed_unit {}; struct PeV_per_c2 : prefixed_unit {}; struct EeV_per_c2 : prefixed_unit {}; struct YeV_per_c2 : prefixed_unit {}; -struct electron_mass : named_scaled_unit {}; -struct proton_mass : named_scaled_unit {}; -struct neutron_mass : named_scaled_unit {}; +struct electron_mass : + named_scaled_unit {}; +struct proton_mass : + named_scaled_unit {}; +struct neutron_mass : + named_scaled_unit {}; struct dim_mass : isq::dim_mass {}; @@ -59,46 +66,110 @@ using mass = quantity; #ifndef UNITS_NO_LITERALS inline namespace literals { -constexpr auto operator"" _q_feV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_feV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_feV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_peV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_peV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_peV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_neV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_neV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_neV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_ueV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ueV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ueV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_meV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_meV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_meV_per_c2(long double l) { return mass(l); } // eV_per_c2 -constexpr auto operator"" _q_eV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_eV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_eV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_keV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_keV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_keV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_MeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_MeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_MeV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_GeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_GeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_GeV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_TeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_TeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_TeV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_PeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_PeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_PeV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_EeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_EeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_EeV_per_c2(long double l) { return mass(l); } -constexpr auto operator"" _q_YeV_per_c2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_YeV_per_c2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_YeV_per_c2(long double l) { return mass(l); } // special HEP masses -constexpr auto operator"" _q_electron_mass(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_electron_mass(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_electron_mass(long double l) { return mass(l); } -constexpr auto operator"" _q_proton_mass(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_proton_mass(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_proton_mass(long double l) { return mass(l); } -constexpr auto operator"" _q_neutron_mass(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_neutron_mass(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_neutron_mass(long double l) { return mass(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -114,7 +185,7 @@ using namespace mass_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::hep @@ -122,8 +193,9 @@ using namespace mass_references; namespace units::aliases::isq::si::hep::inline mass { -template using eV_per_c2g = units::isq::si::hep::mass; +template +using eV_per_c2g = units::isq::si::hep::mass; } // namespace units::aliases::isq::si::hep::inline mass -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-hep/include/units/isq/si/hep/momentum.h b/src/systems/si-hep/include/units/isq/si/hep/momentum.h index aaece772..285f9d21 100644 --- a/src/systems/si-hep/include/units/isq/si/hep/momentum.h +++ b/src/systems/si-hep/include/units/isq/si/hep/momentum.h @@ -35,7 +35,9 @@ namespace units::isq::si::hep { -struct eV_per_c : named_scaled_unit {}; +struct eV_per_c : + named_scaled_unit {}; struct feV_per_c : prefixed_unit {}; struct peV_per_c : prefixed_unit {}; struct neV_per_c : prefixed_unit {}; @@ -58,48 +60,101 @@ using momentum = quantity; inline namespace literals { -constexpr auto operator"" _q_feV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_feV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_feV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_peV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_peV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_peV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_neV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_neV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_neV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_ueV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_ueV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_ueV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_meV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_meV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_meV_per_c(long double l) { return momentum(l); } // eV_per_c -constexpr auto operator"" _q_eV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_eV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_eV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_keV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_keV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_keV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_MeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_MeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_MeV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_GeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_GeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_GeV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_TeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_TeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_TeV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_PeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_PeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_PeV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_EeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_EeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_EeV_per_c(long double l) { return momentum(l); } -constexpr auto operator"" _q_YeV_per_c(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_YeV_per_c(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_YeV_per_c(long double l) { return momentum(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS -} // namespace units::isq::si +} // namespace units::isq::si::hep #ifndef UNITS_NO_ALIASES namespace units::aliases::isq::si::inline momentum { -template using eV_per_c = units::isq::si::hep::momentum; +template +using eV_per_c = units::isq::si::hep::momentum; } // namespace units::aliases::isq::si::inline momentum -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-iau/include/units/isq/si/iau/length.h b/src/systems/si-iau/include/units/isq/si/iau/length.h index 04fbffe9..ce0d1059 100644 --- a/src/systems/si-iau/include/units/isq/si/iau/length.h +++ b/src/systems/si-iau/include/units/isq/si/iau/length.h @@ -49,20 +49,32 @@ struct angstrom : named_scaled_unit(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_ly(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_ly(long double l) { return si::length(l); } // pc -constexpr auto operator"" _q_pc(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_pc(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_pc(long double l) { return si::length(l); } // angstrom -constexpr auto operator"" _q_angstrom(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_angstrom(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_angstrom(long double l) { return si::length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -80,7 +92,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::iau @@ -88,10 +100,13 @@ using namespace length_references; namespace units::aliases::isq::si::iau::inline length { -template using ly = units::isq::si::length; -template using pc = units::isq::si::length; -template using angstrom = units::isq::si::length; +template +using ly = units::isq::si::length; +template +using pc = units::isq::si::length; +template +using angstrom = units::isq::si::length; -} // namespace units::aliases::isq::si::iau +} // namespace units::aliases::isq::si::iau::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-imperial/include/units/isq/si/imperial/length.h b/src/systems/si-imperial/include/units/isq/si/imperial/length.h index 249552cc..eb5978c3 100644 --- a/src/systems/si-imperial/include/units/isq/si/imperial/length.h +++ b/src/systems/si-imperial/include/units/isq/si/imperial/length.h @@ -45,16 +45,24 @@ struct rod : named_scaled_unit {}; inline namespace literals { // ch -constexpr auto operator"" _q_ch(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_ch(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_ch(long double l) { return si::length(l); } // rd -constexpr auto operator"" _q_rd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_rd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_rd(long double l) { return si::length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -71,7 +79,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::imperial @@ -79,9 +87,11 @@ using namespace length_references; namespace units::aliases::isq::si::imperial::inline length { -template using ch = units::isq::si::length; -template using rd = units::isq::si::length; +template +using ch = units::isq::si::length; +template +using rd = units::isq::si::length; } // namespace units::aliases::isq::si::imperial::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/length.h b/src/systems/si-international/include/units/isq/si/international/length.h index 2c28c494..38b7eac3 100644 --- a/src/systems/si-international/include/units/isq/si/international/length.h +++ b/src/systems/si-international/include/units/isq/si/international/length.h @@ -71,40 +71,72 @@ using mil = thou; inline namespace literals { // yd -constexpr auto operator"" _q_yd(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_yd(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_yd(long double l) { return si::length(l); } // ft -constexpr auto operator"" _q_ft(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_ft(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_ft(long double l) { return si::length(l); } // fathom -constexpr auto operator"" _q_fathom(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_fathom(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_fathom(long double l) { return si::length(l); } // in -constexpr auto operator"" _q_in(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_in(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_in(long double l) { return si::length(l); } // mi -constexpr auto operator"" _q_mi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_mi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_mi(long double l) { return si::length(l); } // mi_naut -constexpr auto operator"" _q_naut_mi(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_naut_mi(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_naut_mi(long double l) { return si::length(l); } // thou -constexpr auto operator"" _q_thou(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_thou(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_thou(long double l) { return si::length(l); } // mil -constexpr auto operator"" _q_mil(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_mil(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_mil(long double l) { return si::length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -127,7 +159,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::international @@ -135,15 +167,23 @@ using namespace length_references; namespace units::aliases::isq::si::international::inline length { -template using yd = units::isq::si::length; -template using ft = units::isq::si::length; -template using fathom = units::isq::si::length; -template using in = units::isq::si::length; -template using mi = units::isq::si::length; -template using mi_naut = units::isq::si::length; -template using thou = units::isq::si::length; -template using mil = units::isq::si::length; +template +using yd = units::isq::si::length; +template +using ft = units::isq::si::length; +template +using fathom = units::isq::si::length; +template +using in = units::isq::si::length; +template +using mi = units::isq::si::length; +template +using mi_naut = units::isq::si::length; +template +using thou = units::isq::si::length; +template +using mil = units::isq::si::length; } // namespace units::aliases::isq::si::international::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/speed.h b/src/systems/si-international/include/units/isq/si/international/speed.h index 406cc195..3ce51418 100644 --- a/src/systems/si-international/include/units/isq/si/international/speed.h +++ b/src/systems/si-international/include/units/isq/si/international/speed.h @@ -41,12 +41,16 @@ struct mile_per_hour : derived_unit(l)); return si::speed(static_cast(l)); } +constexpr auto operator"" _q_mi_per_h(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::speed(static_cast(l)); +} constexpr auto operator"" _q_mi_per_h(long double l) { return si::speed(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si::international @@ -54,8 +58,9 @@ constexpr auto operator"" _q_mi_per_h(long double l) { return si::speed using mi_per_h = units::isq::si::speed; +template +using mi_per_h = units::isq::si::speed; } // namespace units::aliases::isq::si::international::inline speed -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-international/include/units/isq/si/international/volume.h b/src/systems/si-international/include/units/isq/si/international/volume.h index 641340ae..7c7b65cc 100644 --- a/src/systems/si-international/include/units/isq/si/international/volume.h +++ b/src/systems/si-international/include/units/isq/si/international/volume.h @@ -42,12 +42,16 @@ struct cubic_foot : derived_unit(l)); return si::volume(static_cast(l)); } +constexpr auto operator"" _q_ft3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::volume(static_cast(l)); +} constexpr auto operator"" _q_ft3(long double l) { return si::volume(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -63,7 +67,7 @@ using namespace volume_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::international @@ -71,8 +75,9 @@ using namespace volume_references; namespace units::aliases::isq::si::international::inline volume { -template using ft3 = units::isq::si::volume; +template +using ft3 = units::isq::si::volume; } // namespace units::aliases::isq::si::international::inline volume -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-typographic/include/units/isq/si/typographic/length.h b/src/systems/si-typographic/include/units/isq/si/typographic/length.h index b319dff5..cb3c691e 100644 --- a/src/systems/si-typographic/include/units/isq/si/typographic/length.h +++ b/src/systems/si-typographic/include/units/isq/si/typographic/length.h @@ -35,7 +35,8 @@ namespace units::isq::si::typographic { -// TODO Conflicts with (https://en.wikipedia.org/wiki/Pica_(typography)), verify correctness of below conversion factors and provide hyperlinks to definitions +// TODO Conflicts with (https://en.wikipedia.org/wiki/Pica_(typography)), verify correctness of below conversion factors +// and provide hyperlinks to definitions struct pica_comp : named_scaled_unit {}; struct pica_prn : named_scaled_unit {}; struct point_comp : named_scaled_unit {}; @@ -46,24 +47,40 @@ struct point_prn : named_scaled_unit(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_pica_comp(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_pica_comp(long double l) { return si::length(l); } // pica prn -constexpr auto operator"" _q_pica_prn(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_pica_prn(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_pica_prn(long double l) { return si::length(l); } // point comp -constexpr auto operator"" _q_point_comp(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_point_comp(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_point_comp(long double l) { return si::length(l); } // point prn -constexpr auto operator"" _q_point_prn(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_point_prn(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_point_prn(long double l) { return si::length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -82,7 +99,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::typographic @@ -90,11 +107,15 @@ using namespace length_references; namespace units::aliases::isq::si::typographic::inline length { -template using pica_comp = units::isq::si::length; -template using pica_prn = units::isq::si::length; -template using point_comp = units::isq::si::length; -template using point_prn = units::isq::si::length; +template +using pica_comp = units::isq::si::length; +template +using pica_prn = units::isq::si::length; +template +using point_comp = units::isq::si::length; +template +using point_prn = units::isq::si::length; } // namespace units::aliases::isq::si::typographic::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si-uscs/include/units/isq/si/uscs/length.h b/src/systems/si-uscs/include/units/isq/si/uscs/length.h index c77e3ccb..b1c06b5f 100644 --- a/src/systems/si-uscs/include/units/isq/si/uscs/length.h +++ b/src/systems/si-uscs/include/units/isq/si/uscs/length.h @@ -50,20 +50,35 @@ struct mile : named_scaled_unit {} inline namespace literals { // ft -constexpr auto operator"" _q_ft_us(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_ft_us(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_ft_us(long double l) { return si::length(l); } // fathom -constexpr auto operator"" _q_fathom_us(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } -constexpr auto operator"" _q_fathom_us(long double l) { return si::length(l); } +constexpr auto operator"" _q_fathom_us(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} +constexpr auto operator"" _q_fathom_us(long double l) +{ + return si::length(l); +} // mi -constexpr auto operator"" _q_mi_us(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return si::length(static_cast(l)); } +constexpr auto operator"" _q_mi_us(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return si::length(static_cast(l)); +} constexpr auto operator"" _q_mi_us(long double l) { return si::length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -81,7 +96,7 @@ using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si::uscs @@ -89,10 +104,13 @@ using namespace length_references; namespace units::aliases::isq::si::uscs::inline length { -template using ft = units::isq::si::length; -template using fathom = units::isq::si::length; -template using mi = units::isq::si::length; +template +using ft = units::isq::si::length; +template +using fathom = units::isq::si::length; +template +using mi = units::isq::si::length; } // namespace units::aliases::isq::si::uscs::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/catalytic_activity.h b/src/systems/si/include/units/isq/si/catalytic_activity.h index 14f48129..9c348d88 100644 --- a/src/systems/si/include/units/isq/si/catalytic_activity.h +++ b/src/systems/si/include/units/isq/si/catalytic_activity.h @@ -30,8 +30,8 @@ // IWYU pragma: end_exports #include -#include #include +#include #include namespace units::isq::si { @@ -60,7 +60,8 @@ struct yottakatal : prefixed_unit {}; struct enzyme_unit : named_scaled_unit {}; -struct dim_catalytic_activity : isq::dim_catalytic_activity {}; +struct dim_catalytic_activity : + isq::dim_catalytic_activity {}; template U, Representation Rep = double> using catalytic_activity = quantity; @@ -70,96 +71,184 @@ using catalytic_activity = quantity; inline namespace literals { // kat -constexpr auto operator"" _q_kat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_kat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_kat(long double l) { return catalytic_activity(l); } // ykat -constexpr auto operator"" _q_ykat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_ykat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_ykat(long double l) { return catalytic_activity(l); } // zkat -constexpr auto operator"" _q_zkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_zkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_zkat(long double l) { return catalytic_activity(l); } // akat -constexpr auto operator"" _q_akat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_akat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_akat(long double l) { return catalytic_activity(l); } // fkat -constexpr auto operator"" _q_fkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_fkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_fkat(long double l) { return catalytic_activity(l); } // pkat -constexpr auto operator"" _q_pkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_pkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_pkat(long double l) { return catalytic_activity(l); } // nkat -constexpr auto operator"" _q_nkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_nkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_nkat(long double l) { return catalytic_activity(l); } // ukat -constexpr auto operator"" _q_ukat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_ukat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_ukat(long double l) { return catalytic_activity(l); } // mkat -constexpr auto operator"" _q_mkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_mkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_mkat(long double l) { return catalytic_activity(l); } // ckat -constexpr auto operator"" _q_ckat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_ckat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_ckat(long double l) { return catalytic_activity(l); } // dkat -constexpr auto operator"" _q_dkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_dkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_dkat(long double l) { return catalytic_activity(l); } // dakat -constexpr auto operator"" _q_dakat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_dakat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_dakat(long double l) { return catalytic_activity(l); } // hkat -constexpr auto operator"" _q_hkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_hkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_hkat(long double l) { return catalytic_activity(l); } // kkat -constexpr auto operator"" _q_kkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_kkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_kkat(long double l) { return catalytic_activity(l); } // Mkat -constexpr auto operator"" _q_Mkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Mkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Mkat(long double l) { return catalytic_activity(l); } // Gkat -constexpr auto operator"" _q_Gkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Gkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Gkat(long double l) { return catalytic_activity(l); } // Tkat -constexpr auto operator"" _q_Tkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Tkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Tkat(long double l) { return catalytic_activity(l); } // Pkat -constexpr auto operator"" _q_Pkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Pkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Pkat(long double l) { return catalytic_activity(l); } // Ekat -constexpr auto operator"" _q_Ekat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Ekat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Ekat(long double l) { return catalytic_activity(l); } // Zkat -constexpr auto operator"" _q_Zkat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Zkat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Zkat(long double l) { return catalytic_activity(l); } // Ykat -constexpr auto operator"" _q_Ykat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_Ykat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_Ykat(long double l) { return catalytic_activity(l); } // U -constexpr auto operator"" _q_U(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return catalytic_activity(static_cast(l)); } +constexpr auto operator"" _q_U(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return catalytic_activity(static_cast(l)); +} constexpr auto operator"" _q_U(long double l) { return catalytic_activity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -196,7 +285,7 @@ using namespace catalytic_activity_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -204,29 +293,51 @@ using namespace catalytic_activity_references; namespace units::aliases::isq::si::inline catalytic_activity { -template using kat = units::isq::si::catalytic_activity; -template using ykat = units::isq::si::catalytic_activity; -template using zkat = units::isq::si::catalytic_activity; -template using akat = units::isq::si::catalytic_activity; -template using fkat = units::isq::si::catalytic_activity; -template using pkat = units::isq::si::catalytic_activity; -template using nkat = units::isq::si::catalytic_activity; -template using ukat = units::isq::si::catalytic_activity; -template using mkat = units::isq::si::catalytic_activity; -template using ckat = units::isq::si::catalytic_activity; -template using dkat = units::isq::si::catalytic_activity; -template using dakat = units::isq::si::catalytic_activity; -template using hkat = units::isq::si::catalytic_activity; -template using kkat = units::isq::si::catalytic_activity; -template using Mkat = units::isq::si::catalytic_activity; -template using Gkat = units::isq::si::catalytic_activity; -template using Tkat = units::isq::si::catalytic_activity; -template using Pkat = units::isq::si::catalytic_activity; -template using Ekat = units::isq::si::catalytic_activity; -template using Zkat = units::isq::si::catalytic_activity; -template using Ykat = units::isq::si::catalytic_activity; -template using U = units::isq::si::catalytic_activity; +template +using kat = units::isq::si::catalytic_activity; +template +using ykat = units::isq::si::catalytic_activity; +template +using zkat = units::isq::si::catalytic_activity; +template +using akat = units::isq::si::catalytic_activity; +template +using fkat = units::isq::si::catalytic_activity; +template +using pkat = units::isq::si::catalytic_activity; +template +using nkat = units::isq::si::catalytic_activity; +template +using ukat = units::isq::si::catalytic_activity; +template +using mkat = units::isq::si::catalytic_activity; +template +using ckat = units::isq::si::catalytic_activity; +template +using dkat = units::isq::si::catalytic_activity; +template +using dakat = units::isq::si::catalytic_activity; +template +using hkat = units::isq::si::catalytic_activity; +template +using kkat = units::isq::si::catalytic_activity; +template +using Mkat = units::isq::si::catalytic_activity; +template +using Gkat = units::isq::si::catalytic_activity; +template +using Tkat = units::isq::si::catalytic_activity; +template +using Pkat = units::isq::si::catalytic_activity; +template +using Ekat = units::isq::si::catalytic_activity; +template +using Zkat = units::isq::si::catalytic_activity; +template +using Ykat = units::isq::si::catalytic_activity; +template +using U = units::isq::si::catalytic_activity; } // namespace units::aliases::isq::si::inline catalytic_activity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/charge_density.h b/src/systems/si/include/units/isq/si/charge_density.h index ec23d422..b50d0c03 100644 --- a/src/systems/si/include/units/isq/si/charge_density.h +++ b/src/systems/si/include/units/isq/si/charge_density.h @@ -38,8 +38,11 @@ namespace units::isq::si { struct coulomb_per_metre_cub : unit {}; struct coulomb_per_metre_sq : unit {}; -struct dim_charge_density : isq::dim_charge_density {}; -struct dim_surface_charge_density : isq::dim_surface_charge_density {}; +struct dim_charge_density : + isq::dim_charge_density {}; +struct dim_surface_charge_density : + isq::dim_surface_charge_density { +}; template U, Representation Rep = double> using charge_density = quantity; @@ -52,16 +55,27 @@ using surface_charge_density = quantity; inline namespace literals { // C/m³ -constexpr auto operator"" _q_C_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return charge_density(static_cast(l)); } +constexpr auto operator"" _q_C_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return charge_density(static_cast(l)); +} constexpr auto operator"" _q_C_per_m3(long double l) { return charge_density(l); } // C/m² -constexpr auto operator"" _q_C_per_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return surface_charge_density(static_cast(l)); } -constexpr auto operator"" _q_C_per_m2(long double l) { return surface_charge_density(l); } +constexpr auto operator"" _q_C_per_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return surface_charge_density(static_cast(l)); +} +constexpr auto operator"" _q_C_per_m2(long double l) +{ + return surface_charge_density(l); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -69,9 +83,11 @@ constexpr auto operator"" _q_C_per_m2(long double l) { return surface_charge_den namespace units::aliases::isq::si::inline charge_density { -template using C_per_m3 = units::isq::si::charge_density; -template using C_per_m2 = units::isq::si::surface_charge_density; +template +using C_per_m3 = units::isq::si::charge_density; +template +using C_per_m2 = units::isq::si::surface_charge_density; } // namespace units::aliases::isq::si::inline charge_density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/constants.h b/src/systems/si/include/units/isq/si/constants.h index ceda7eb6..a0097532 100644 --- a/src/systems/si/include/units/isq/si/constants.h +++ b/src/systems/si/include/units/isq/si/constants.h @@ -23,12 +23,12 @@ #pragma once #include -#include #include #include #include #include #include +#include namespace units::isq::si::si2019 { diff --git a/src/systems/si/include/units/isq/si/current_density.h b/src/systems/si/include/units/isq/si/current_density.h index 828587d0..4017414c 100644 --- a/src/systems/si/include/units/isq/si/current_density.h +++ b/src/systems/si/include/units/isq/si/current_density.h @@ -37,7 +37,8 @@ namespace units::isq::si { struct ampere_per_metre_sq : unit {}; -struct dim_current_density : isq::dim_current_density {}; +struct dim_current_density : + isq::dim_current_density {}; template U, Representation Rep = double> using current_density = quantity; @@ -47,12 +48,16 @@ using current_density = quantity; inline namespace literals { // A / m² -constexpr auto operator"" _q_A_per_m2(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return current_density(static_cast(l)); } +constexpr auto operator"" _q_A_per_m2(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return current_density(static_cast(l)); +} constexpr auto operator"" _q_A_per_m2(long double l) { return current_density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +65,9 @@ constexpr auto operator"" _q_A_per_m2(long double l) { return current_density using A_per_m2 = units::isq::si::current_density; +template +using A_per_m2 = units::isq::si::current_density; } // namespace units::aliases::isq::si::inline current_density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/dynamic_viscosity.h b/src/systems/si/include/units/isq/si/dynamic_viscosity.h index 4b9b4339..763eb66c 100644 --- a/src/systems/si/include/units/isq/si/dynamic_viscosity.h +++ b/src/systems/si/include/units/isq/si/dynamic_viscosity.h @@ -28,14 +28,15 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { struct pascal_second : unit {}; -struct dim_dynamic_viscosity : isq::dim_dynamic_viscosity {}; +struct dim_dynamic_viscosity : + isq::dim_dynamic_viscosity {}; template U, Representation Rep = double> using dynamic_viscosity = quantity; @@ -45,12 +46,16 @@ using dynamic_viscosity = quantity; inline namespace literals { // Pa·s -constexpr auto operator"" _q_Pa_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return dynamic_viscosity(static_cast(l)); } +constexpr auto operator"" _q_Pa_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return dynamic_viscosity(static_cast(l)); +} constexpr auto operator"" _q_Pa_s(long double l) { return dynamic_viscosity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +63,9 @@ constexpr auto operator"" _q_Pa_s(long double l) { return dynamic_viscosity using Pa_s = units::isq::si::dynamic_viscosity; +template +using Pa_s = units::isq::si::dynamic_viscosity; } // namespace units::aliases::isq::si::inline dynamic_viscosity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_charge.h b/src/systems/si/include/units/isq/si/electric_charge.h index 6b522952..cb79b848 100644 --- a/src/systems/si/include/units/isq/si/electric_charge.h +++ b/src/systems/si/include/units/isq/si/electric_charge.h @@ -47,12 +47,16 @@ using electric_charge = quantity; inline namespace literals { // C -constexpr auto operator"" _q_C(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_charge(static_cast(l)); } +constexpr auto operator"" _q_C(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_charge(static_cast(l)); +} constexpr auto operator"" _q_C(long double l) { return electric_charge(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -68,7 +72,7 @@ using namespace electric_charge_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -76,8 +80,9 @@ using namespace electric_charge_references; namespace units::aliases::isq::si::inline electric_charge { -template using C = units::isq::si::electric_charge; +template +using C = units::isq::si::electric_charge; } // namespace units::aliases::isq::si::inline electric_charge -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_current.h b/src/systems/si/include/units/isq/si/electric_current.h index f71b86bf..23c12021 100644 --- a/src/systems/si/include/units/isq/si/electric_current.h +++ b/src/systems/si/include/units/isq/si/electric_current.h @@ -66,92 +66,176 @@ using electric_current = quantity; inline namespace literals { // A -constexpr auto operator"" _q_A(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_A(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_A(long double l) { return electric_current(l); } // yA -constexpr auto operator"" _q_yA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_yA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_yA(long double l) { return electric_current(l); } // zA -constexpr auto operator"" _q_zA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_zA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_zA(long double l) { return electric_current(l); } // aA -constexpr auto operator"" _q_aA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_aA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_aA(long double l) { return electric_current(l); } // fA -constexpr auto operator"" _q_fA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_fA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_fA(long double l) { return electric_current(l); } // pA -constexpr auto operator"" _q_pA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_pA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_pA(long double l) { return electric_current(l); } // nA -constexpr auto operator"" _q_nA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_nA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_nA(long double l) { return electric_current(l); } // uA -constexpr auto operator"" _q_uA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_uA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_uA(long double l) { return electric_current(l); } // mA -constexpr auto operator"" _q_mA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_mA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_mA(long double l) { return electric_current(l); } // cA -constexpr auto operator"" _q_cA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_cA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_cA(long double l) { return electric_current(l); } // dA -constexpr auto operator"" _q_dA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_dA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_dA(long double l) { return electric_current(l); } // daA -constexpr auto operator"" _q_daA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_daA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_daA(long double l) { return electric_current(l); } // hA -constexpr auto operator"" _q_hA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_hA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_hA(long double l) { return electric_current(l); } // kA -constexpr auto operator"" _q_kA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_kA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_kA(long double l) { return electric_current(l); } // MA -constexpr auto operator"" _q_MA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_MA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_MA(long double l) { return electric_current(l); } // GA -constexpr auto operator"" _q_GA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_GA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_GA(long double l) { return electric_current(l); } // TA -constexpr auto operator"" _q_TA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_TA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_TA(long double l) { return electric_current(l); } // PA -constexpr auto operator"" _q_PA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_PA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_PA(long double l) { return electric_current(l); } // EA -constexpr auto operator"" _q_EA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_EA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_EA(long double l) { return electric_current(l); } // ZA -constexpr auto operator"" _q_ZA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_ZA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_ZA(long double l) { return electric_current(l); } // YA -constexpr auto operator"" _q_YA(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_current(static_cast(l)); } +constexpr auto operator"" _q_YA(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_current(static_cast(l)); +} constexpr auto operator"" _q_YA(long double l) { return electric_current(l); } -} // namespace literals +} // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -187,7 +271,7 @@ using namespace electric_current_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -195,28 +279,49 @@ using namespace electric_current_references; namespace units::aliases::isq::si::inline electric_current { -template using A = units::isq::si::electric_current; -template using yA = units::isq::si::electric_current; -template using zA = units::isq::si::electric_current; -template using aA = units::isq::si::electric_current; -template using fA = units::isq::si::electric_current; -template using pA = units::isq::si::electric_current; -template using nA = units::isq::si::electric_current; -template using uA = units::isq::si::electric_current; -template using mA = units::isq::si::electric_current; -template using cA = units::isq::si::electric_current; -template using dA = units::isq::si::electric_current; -template using daA = units::isq::si::electric_current; -template using hA = units::isq::si::electric_current; -template using kA = units::isq::si::electric_current; -template using MA = units::isq::si::electric_current; -template using GA = units::isq::si::electric_current; -template using TA = units::isq::si::electric_current; -template using PA = units::isq::si::electric_current; -template using EA = units::isq::si::electric_current; -template using ZA = units::isq::si::electric_current; -template using YA = units::isq::si::electric_current; +template +using A = units::isq::si::electric_current; +template +using yA = units::isq::si::electric_current; +template +using zA = units::isq::si::electric_current; +template +using aA = units::isq::si::electric_current; +template +using fA = units::isq::si::electric_current; +template +using pA = units::isq::si::electric_current; +template +using nA = units::isq::si::electric_current; +template +using uA = units::isq::si::electric_current; +template +using mA = units::isq::si::electric_current; +template +using cA = units::isq::si::electric_current; +template +using dA = units::isq::si::electric_current; +template +using daA = units::isq::si::electric_current; +template +using hA = units::isq::si::electric_current; +template +using kA = units::isq::si::electric_current; +template +using MA = units::isq::si::electric_current; +template +using GA = units::isq::si::electric_current; +template +using TA = units::isq::si::electric_current; +template +using PA = units::isq::si::electric_current; +template +using EA = units::isq::si::electric_current; +template +using ZA = units::isq::si::electric_current; +template +using YA = units::isq::si::electric_current; } // namespace units::aliases::isq::si::inline electric_current -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/electric_field_strength.h b/src/systems/si/include/units/isq/si/electric_field_strength.h index 290b4dbb..49e843f7 100644 --- a/src/systems/si/include/units/isq/si/electric_field_strength.h +++ b/src/systems/si/include/units/isq/si/electric_field_strength.h @@ -34,7 +34,8 @@ namespace units::isq::si { struct volt_per_metre : unit {}; -struct dim_electric_field_strength : isq::dim_electric_field_strength {}; +struct dim_electric_field_strength : + isq::dim_electric_field_strength {}; template U, Representation Rep = double> using electric_field_strength = quantity; @@ -44,12 +45,16 @@ using electric_field_strength = quantity; inline namespace literals { // V/m -constexpr auto operator"" _q_V_per_m(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return electric_field_strength(static_cast(l)); } +constexpr auto operator"" _q_V_per_m(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return electric_field_strength(static_cast(l)); +} constexpr auto operator"" _q_V_per_m(long double l) { return electric_field_strength(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -57,8 +62,9 @@ constexpr auto operator"" _q_V_per_m(long double l) { return electric_field_stre namespace units::aliases::isq::si::inline electric_field_strength { -template using V_per_m = units::isq::si::electric_field_strength; +template +using V_per_m = units::isq::si::electric_field_strength; } // namespace units::aliases::isq::si::inline electric_field_strength -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/energy_density.h b/src/systems/si/include/units/isq/si/energy_density.h index c451b045..3e4e501e 100644 --- a/src/systems/si/include/units/isq/si/energy_density.h +++ b/src/systems/si/include/units/isq/si/energy_density.h @@ -45,12 +45,16 @@ using energy_density = quantity; inline namespace literals { // N/m -constexpr auto operator"" _q_J_per_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return energy_density(static_cast(l)); } +constexpr auto operator"" _q_J_per_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return energy_density(static_cast(l)); +} constexpr auto operator"" _q_J_per_m3(long double l) { return energy_density(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +62,9 @@ constexpr auto operator"" _q_J_per_m3(long double l) { return energy_density using J_per_m3 = units::isq::si::energy_density; +template +using J_per_m3 = units::isq::si::energy_density; } // namespace units::aliases::isq::si::inline energy_density -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/frequency.h b/src/systems/si/include/units/isq/si/frequency.h index e3a9121f..0a9bd90a 100644 --- a/src/systems/si/include/units/isq/si/frequency.h +++ b/src/systems/si/include/units/isq/si/frequency.h @@ -62,76 +62,144 @@ using frequency = quantity; inline namespace literals { // Hz -constexpr auto operator"" _q_Hz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_Hz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_Hz(long double l) { return frequency(l); } // yHz -constexpr auto operator"" _q_yHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_yHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_yHz(long double l) { return frequency(l); } // zHz -constexpr auto operator"" _q_zHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_zHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_zHz(long double l) { return frequency(l); } // aHz -constexpr auto operator"" _q_aHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_aHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_aHz(long double l) { return frequency(l); } // fHz -constexpr auto operator"" _q_fHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_fHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_fHz(long double l) { return frequency(l); } // pHz -constexpr auto operator"" _q_pHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_pHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_pHz(long double l) { return frequency(l); } // nHz -constexpr auto operator"" _q_nHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_nHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_nHz(long double l) { return frequency(l); } // uHz -constexpr auto operator"" _q_uHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_uHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_uHz(long double l) { return frequency(l); } // mHz -constexpr auto operator"" _q_mHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_mHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_mHz(long double l) { return frequency(l); } // kHz -constexpr auto operator"" _q_kHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_kHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_kHz(long double l) { return frequency(l); } // MHz -constexpr auto operator"" _q_MHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_MHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_MHz(long double l) { return frequency(l); } // GHz -constexpr auto operator"" _q_GHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_GHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_GHz(long double l) { return frequency(l); } // THz -constexpr auto operator"" _q_THz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_THz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_THz(long double l) { return frequency(l); } // PHz -constexpr auto operator"" _q_PHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_PHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_PHz(long double l) { return frequency(l); } // EHz -constexpr auto operator"" _q_EHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_EHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_EHz(long double l) { return frequency(l); } // ZHz -constexpr auto operator"" _q_ZHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_ZHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_ZHz(long double l) { return frequency(l); } // YHz -constexpr auto operator"" _q_YHz(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return frequency(static_cast(l)); } +constexpr auto operator"" _q_YHz(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return frequency(static_cast(l)); +} constexpr auto operator"" _q_YHz(long double l) { return frequency(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -163,7 +231,7 @@ using namespace frequency_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -171,24 +239,41 @@ using namespace frequency_references; namespace units::aliases::isq::si::inline frequency { -template using Hz = units::isq::si::frequency; -template using yHz = units::isq::si::frequency; -template using zHz = units::isq::si::frequency; -template using aHz = units::isq::si::frequency; -template using fHz = units::isq::si::frequency; -template using pHz = units::isq::si::frequency; -template using nHz = units::isq::si::frequency; -template using uHz = units::isq::si::frequency; -template using mHz = units::isq::si::frequency; -template using kHz = units::isq::si::frequency; -template using MHz = units::isq::si::frequency; -template using GHz = units::isq::si::frequency; -template using THz = units::isq::si::frequency; -template using PHz = units::isq::si::frequency; -template using EHz = units::isq::si::frequency; -template using ZHz = units::isq::si::frequency; -template using YHz = units::isq::si::frequency; +template +using Hz = units::isq::si::frequency; +template +using yHz = units::isq::si::frequency; +template +using zHz = units::isq::si::frequency; +template +using aHz = units::isq::si::frequency; +template +using fHz = units::isq::si::frequency; +template +using pHz = units::isq::si::frequency; +template +using nHz = units::isq::si::frequency; +template +using uHz = units::isq::si::frequency; +template +using mHz = units::isq::si::frequency; +template +using kHz = units::isq::si::frequency; +template +using MHz = units::isq::si::frequency; +template +using GHz = units::isq::si::frequency; +template +using THz = units::isq::si::frequency; +template +using PHz = units::isq::si::frequency; +template +using EHz = units::isq::si::frequency; +template +using ZHz = units::isq::si::frequency; +template +using YHz = units::isq::si::frequency; } // namespace units::aliases::isq::si::inline frequency -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/heat_capacity.h b/src/systems/si/include/units/isq/si/heat_capacity.h index 815306fd..b264f59d 100644 --- a/src/systems/si/include/units/isq/si/heat_capacity.h +++ b/src/systems/si/include/units/isq/si/heat_capacity.h @@ -28,10 +28,10 @@ #include // IWYU pragma: end_exports -#include +#include #include #include -#include +#include #include namespace units::isq::si { @@ -40,9 +40,14 @@ struct joule_per_kelvin : unit {}; struct joule_per_kilogram_kelvin : unit {}; struct joule_per_mole_kelvin : unit {}; -struct dim_heat_capacity : isq::dim_heat_capacity {}; -struct dim_specific_heat_capacity : isq::dim_specific_heat_capacity {}; -struct dim_molar_heat_capacity : isq::dim_molar_heat_capacity {}; +struct dim_heat_capacity : + isq::dim_heat_capacity {}; +struct dim_specific_heat_capacity : + isq::dim_specific_heat_capacity {}; +struct dim_molar_heat_capacity : + isq::dim_molar_heat_capacity {}; template U, Representation Rep = double> using heat_capacity = quantity; @@ -58,20 +63,38 @@ using molar_heat_capacity = quantity; inline namespace literals { // J/K -constexpr auto operator"" _q_J_per_K(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return heat_capacity(static_cast(l)); } +constexpr auto operator"" _q_J_per_K(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return heat_capacity(static_cast(l)); +} constexpr auto operator"" _q_J_per_K(long double l) { return heat_capacity(l); } // J/(kg·K) -constexpr auto operator"" _q_J_per_kg_K(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return specific_heat_capacity(static_cast(l)); } -constexpr auto operator"" _q_J_per_kg_K(long double l) { return specific_heat_capacity(l); } +constexpr auto operator"" _q_J_per_kg_K(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return specific_heat_capacity(static_cast(l)); +} +constexpr auto operator"" _q_J_per_kg_K(long double l) +{ + return specific_heat_capacity(l); +} // J/(mol·K) -constexpr auto operator"" _q_J_per_mol_K(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return molar_heat_capacity(static_cast(l)); } -constexpr auto operator"" _q_J_per_mol_K(long double l) { return molar_heat_capacity(l); } +constexpr auto operator"" _q_J_per_mol_K(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return molar_heat_capacity(static_cast(l)); +} +constexpr auto operator"" _q_J_per_mol_K(long double l) +{ + return molar_heat_capacity(l); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -79,10 +102,13 @@ constexpr auto operator"" _q_J_per_mol_K(long double l) { return molar_heat_capa namespace units::aliases::isq::si::heat_capacity { -template using J_per_K = units::isq::si::heat_capacity; -template using J_per_kg_K = units::isq::si::specific_heat_capacity; -template using J_per_mol_K = units::isq::si::molar_heat_capacity; +template +using J_per_K = units::isq::si::heat_capacity; +template +using J_per_kg_K = units::isq::si::specific_heat_capacity; +template +using J_per_mol_K = units::isq::si::molar_heat_capacity; } // namespace units::aliases::isq::si::heat_capacity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/inductance.h b/src/systems/si/include/units/isq/si/inductance.h index 3ca6a0d9..e3eb6ee7 100644 --- a/src/systems/si/include/units/isq/si/inductance.h +++ b/src/systems/si/include/units/isq/si/inductance.h @@ -29,8 +29,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { @@ -64,76 +64,144 @@ using inductance = quantity; inline namespace literals { // H -constexpr auto operator"" _q_H(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_H(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_H(long double l) { return inductance(l); } // yH -constexpr auto operator"" _q_yH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_yH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_yH(long double l) { return inductance(l); } // zH -constexpr auto operator"" _q_zH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_zH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_zH(long double l) { return inductance(l); } // aH -constexpr auto operator"" _q_aH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_aH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_aH(long double l) { return inductance(l); } // fH -constexpr auto operator"" _q_fH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_fH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_fH(long double l) { return inductance(l); } // pH -constexpr auto operator"" _q_pH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_pH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_pH(long double l) { return inductance(l); } // nH -constexpr auto operator"" _q_nH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_nH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_nH(long double l) { return inductance(l); } // µH -constexpr auto operator"" _q_uH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_uH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_uH(long double l) { return inductance(l); } // mH -constexpr auto operator"" _q_mH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_mH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_mH(long double l) { return inductance(l); } // kH -constexpr auto operator"" _q_kH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_kH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_kH(long double l) { return inductance(l); } // MH -constexpr auto operator"" _q_MH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_MH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_MH(long double l) { return inductance(l); } // GH -constexpr auto operator"" _q_GH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_GH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_GH(long double l) { return inductance(l); } // TH -constexpr auto operator"" _q_TH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_TH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_TH(long double l) { return inductance(l); } // PH -constexpr auto operator"" _q_PH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_PH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_PH(long double l) { return inductance(l); } // EH -constexpr auto operator"" _q_EH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_EH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_EH(long double l) { return inductance(l); } // ZH -constexpr auto operator"" _q_ZH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_ZH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_ZH(long double l) { return inductance(l); } // YH -constexpr auto operator"" _q_YH(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return inductance(static_cast(l)); } +constexpr auto operator"" _q_YH(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return inductance(static_cast(l)); +} constexpr auto operator"" _q_YH(long double l) { return inductance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -165,7 +233,7 @@ using namespace inductance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -173,24 +241,41 @@ using namespace inductance_references; namespace units::aliases::isq::si::inline inductance { -template using H = units::isq::si::inductance; -template using yH = units::isq::si::inductance; -template using zH = units::isq::si::inductance; -template using aH = units::isq::si::inductance; -template using fH = units::isq::si::inductance; -template using pH = units::isq::si::inductance; -template using nH = units::isq::si::inductance; -template using uH = units::isq::si::inductance; -template using mH = units::isq::si::inductance; -template using kH = units::isq::si::inductance; -template using MH = units::isq::si::inductance; -template using GH = units::isq::si::inductance; -template using TH = units::isq::si::inductance; -template using PH = units::isq::si::inductance; -template using EH = units::isq::si::inductance; -template using ZH = units::isq::si::inductance; -template using YH = units::isq::si::inductance; +template +using H = units::isq::si::inductance; +template +using yH = units::isq::si::inductance; +template +using zH = units::isq::si::inductance; +template +using aH = units::isq::si::inductance; +template +using fH = units::isq::si::inductance; +template +using pH = units::isq::si::inductance; +template +using nH = units::isq::si::inductance; +template +using uH = units::isq::si::inductance; +template +using mH = units::isq::si::inductance; +template +using kH = units::isq::si::inductance; +template +using MH = units::isq::si::inductance; +template +using GH = units::isq::si::inductance; +template +using TH = units::isq::si::inductance; +template +using PH = units::isq::si::inductance; +template +using EH = units::isq::si::inductance; +template +using ZH = units::isq::si::inductance; +template +using YH = units::isq::si::inductance; } // namespace units::aliases::isq::si::inline inductance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/length.h b/src/systems/si/include/units/isq/si/length.h index e1a64ff5..eee2c9d2 100644 --- a/src/systems/si/include/units/isq/si/length.h +++ b/src/systems/si/include/units/isq/si/length.h @@ -68,96 +68,184 @@ using length = quantity; inline namespace literals { // m -constexpr auto operator"" _q_m(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_m(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_m(long double l) { return length(l); } // ym -constexpr auto operator"" _q_ym(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_ym(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_ym(long double l) { return length(l); } // zm -constexpr auto operator"" _q_zm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_zm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_zm(long double l) { return length(l); } // am -constexpr auto operator"" _q_am(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_am(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_am(long double l) { return length(l); } // fm -constexpr auto operator"" _q_fm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_fm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_fm(long double l) { return length(l); } // pm -constexpr auto operator"" _q_pm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_pm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_pm(long double l) { return length(l); } // nm -constexpr auto operator"" _q_nm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_nm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_nm(long double l) { return length(l); } // um -constexpr auto operator"" _q_um(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_um(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_um(long double l) { return length(l); } // mm -constexpr auto operator"" _q_mm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_mm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_mm(long double l) { return length(l); } // cm -constexpr auto operator"" _q_cm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_cm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_cm(long double l) { return length(l); } // dm -constexpr auto operator"" _q_dm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_dm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_dm(long double l) { return length(l); } // dam -constexpr auto operator"" _q_dam(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_dam(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_dam(long double l) { return length(l); } // hm -constexpr auto operator"" _q_hm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_hm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_hm(long double l) { return length(l); } // km -constexpr auto operator"" _q_km(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_km(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_km(long double l) { return length(l); } // Mm -constexpr auto operator"" _q_Mm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Mm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Mm(long double l) { return length(l); } // Gm -constexpr auto operator"" _q_Gm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Gm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Gm(long double l) { return length(l); } // Tm -constexpr auto operator"" _q_Tm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Tm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Tm(long double l) { return length(l); } // Pm -constexpr auto operator"" _q_Pm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Pm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Pm(long double l) { return length(l); } // Em -constexpr auto operator"" _q_Em(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Em(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Em(long double l) { return length(l); } // Zm -constexpr auto operator"" _q_Zm(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Zm(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Zm(long double l) { return length(l); } // Ym -constexpr auto operator"" _q_Ym(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_Ym(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_Ym(long double l) { return length(l); } // au -constexpr auto operator"" _q_au(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return length(static_cast(l)); } +constexpr auto operator"" _q_au(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return length(static_cast(l)); +} constexpr auto operator"" _q_au(long double l) { return length(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -188,13 +276,13 @@ inline constexpr auto au = reference{}; } // namespace length_references -namespace references { +namespace references { using namespace length_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -202,29 +290,51 @@ using namespace length_references; namespace units::aliases::isq::si::inline length { -template using m = units::isq::si::length; -template using ym = units::isq::si::length; -template using zm = units::isq::si::length; -template using am = units::isq::si::length; -template using fm = units::isq::si::length; -template using pm = units::isq::si::length; -template using nm = units::isq::si::length; -template using um = units::isq::si::length; -template using mm = units::isq::si::length; -template using cm = units::isq::si::length; -template using dm = units::isq::si::length; -template using dam = units::isq::si::length; -template using hm = units::isq::si::length; -template using km = units::isq::si::length; -template using Mm = units::isq::si::length; -template using Gm = units::isq::si::length; -template using Tm = units::isq::si::length; -template using Pm = units::isq::si::length; -template using Em = units::isq::si::length; -template using Zm = units::isq::si::length; -template using Ym = units::isq::si::length; -template using au = units::isq::si::length; +template +using m = units::isq::si::length; +template +using ym = units::isq::si::length; +template +using zm = units::isq::si::length; +template +using am = units::isq::si::length; +template +using fm = units::isq::si::length; +template +using pm = units::isq::si::length; +template +using nm = units::isq::si::length; +template +using um = units::isq::si::length; +template +using mm = units::isq::si::length; +template +using cm = units::isq::si::length; +template +using dm = units::isq::si::length; +template +using dam = units::isq::si::length; +template +using hm = units::isq::si::length; +template +using km = units::isq::si::length; +template +using Mm = units::isq::si::length; +template +using Gm = units::isq::si::length; +template +using Tm = units::isq::si::length; +template +using Pm = units::isq::si::length; +template +using Em = units::isq::si::length; +template +using Zm = units::isq::si::length; +template +using Ym = units::isq::si::length; +template +using au = units::isq::si::length; } // namespace units::aliases::isq::si::inline length -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/magnetic_flux.h b/src/systems/si/include/units/isq/si/magnetic_flux.h index 78f22854..57c1317d 100644 --- a/src/systems/si/include/units/isq/si/magnetic_flux.h +++ b/src/systems/si/include/units/isq/si/magnetic_flux.h @@ -29,8 +29,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include namespace units::isq::si { @@ -64,76 +64,144 @@ using magnetic_flux = quantity; inline namespace literals { // Wb -constexpr auto operator"" _q_Wb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_Wb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_Wb(long double l) { return magnetic_flux(l); } // yWb -constexpr auto operator"" _q_yWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_yWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_yWb(long double l) { return magnetic_flux(l); } // zWb -constexpr auto operator"" _q_zWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_zWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_zWb(long double l) { return magnetic_flux(l); } // aWb -constexpr auto operator"" _q_aWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_aWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_aWb(long double l) { return magnetic_flux(l); } // fWb -constexpr auto operator"" _q_fWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_fWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_fWb(long double l) { return magnetic_flux(l); } // pWb -constexpr auto operator"" _q_pWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_pWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_pWb(long double l) { return magnetic_flux(l); } // nWb -constexpr auto operator"" _q_nWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_nWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_nWb(long double l) { return magnetic_flux(l); } // µWb -constexpr auto operator"" _q_uWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_uWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_uWb(long double l) { return magnetic_flux(l); } // mWb -constexpr auto operator"" _q_mWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_mWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_mWb(long double l) { return magnetic_flux(l); } // kWb -constexpr auto operator"" _q_kWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_kWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_kWb(long double l) { return magnetic_flux(l); } // MWb -constexpr auto operator"" _q_MWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_MWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_MWb(long double l) { return magnetic_flux(l); } // GWb -constexpr auto operator"" _q_GWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_GWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_GWb(long double l) { return magnetic_flux(l); } // TWb -constexpr auto operator"" _q_TWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_TWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_TWb(long double l) { return magnetic_flux(l); } // PWb -constexpr auto operator"" _q_PWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_PWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_PWb(long double l) { return magnetic_flux(l); } // EWb -constexpr auto operator"" _q_EWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_EWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_EWb(long double l) { return magnetic_flux(l); } // ZWb -constexpr auto operator"" _q_ZWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_ZWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_ZWb(long double l) { return magnetic_flux(l); } // YWb -constexpr auto operator"" _q_YWb(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_flux(static_cast(l)); } +constexpr auto operator"" _q_YWb(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_flux(static_cast(l)); +} constexpr auto operator"" _q_YWb(long double l) { return magnetic_flux(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -165,7 +233,7 @@ using namespace magnetic_flux_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -173,24 +241,41 @@ using namespace magnetic_flux_references; namespace units::aliases::isq::si::inline magnetic_flux { -template using Wb = units::isq::si::magnetic_flux; -template using yWb = units::isq::si::magnetic_flux; -template using zWb = units::isq::si::magnetic_flux; -template using aWb = units::isq::si::magnetic_flux; -template using fWb = units::isq::si::magnetic_flux; -template using pWb = units::isq::si::magnetic_flux; -template using nWb = units::isq::si::magnetic_flux; -template using uWb = units::isq::si::magnetic_flux; -template using mWb = units::isq::si::magnetic_flux; -template using kWb = units::isq::si::magnetic_flux; -template using MWb = units::isq::si::magnetic_flux; -template using GWb = units::isq::si::magnetic_flux; -template using TWb = units::isq::si::magnetic_flux; -template using PWb = units::isq::si::magnetic_flux; -template using EWb = units::isq::si::magnetic_flux; -template using ZWb = units::isq::si::magnetic_flux; -template using YWb = units::isq::si::magnetic_flux; +template +using Wb = units::isq::si::magnetic_flux; +template +using yWb = units::isq::si::magnetic_flux; +template +using zWb = units::isq::si::magnetic_flux; +template +using aWb = units::isq::si::magnetic_flux; +template +using fWb = units::isq::si::magnetic_flux; +template +using pWb = units::isq::si::magnetic_flux; +template +using nWb = units::isq::si::magnetic_flux; +template +using uWb = units::isq::si::magnetic_flux; +template +using mWb = units::isq::si::magnetic_flux; +template +using kWb = units::isq::si::magnetic_flux; +template +using MWb = units::isq::si::magnetic_flux; +template +using GWb = units::isq::si::magnetic_flux; +template +using TWb = units::isq::si::magnetic_flux; +template +using PWb = units::isq::si::magnetic_flux; +template +using EWb = units::isq::si::magnetic_flux; +template +using ZWb = units::isq::si::magnetic_flux; +template +using YWb = units::isq::si::magnetic_flux; } // namespace units::aliases::isq::si::inline magnetic_flux -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/magnetic_induction.h b/src/systems/si/include/units/isq/si/magnetic_induction.h index 71a3a3e7..353a3af0 100644 --- a/src/systems/si/include/units/isq/si/magnetic_induction.h +++ b/src/systems/si/include/units/isq/si/magnetic_induction.h @@ -29,10 +29,10 @@ #include // IWYU pragma: end_exports -#include -#include #include #include +#include +#include #include namespace units::isq::si { @@ -58,7 +58,8 @@ struct yottatesla : prefixed_unit {}; struct gauss : named_scaled_unit {}; -struct dim_magnetic_induction : isq::dim_magnetic_induction {}; +struct dim_magnetic_induction : + isq::dim_magnetic_induction {}; template U, Representation Rep = double> using magnetic_induction = quantity; @@ -68,80 +69,152 @@ using magnetic_induction = quantity; inline namespace literals { // T -constexpr auto operator"" _q_T(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_T(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_T(long double l) { return magnetic_induction(l); } // yT -constexpr auto operator"" _q_yT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_yT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_yT(long double l) { return magnetic_induction(l); } // zT -constexpr auto operator"" _q_zT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_zT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_zT(long double l) { return magnetic_induction(l); } // aT -constexpr auto operator"" _q_aT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_aT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_aT(long double l) { return magnetic_induction(l); } // fT -constexpr auto operator"" _q_fT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_fT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_fT(long double l) { return magnetic_induction(l); } // pT -constexpr auto operator"" _q_pT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_pT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_pT(long double l) { return magnetic_induction(l); } // nT -constexpr auto operator"" _q_nT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_nT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_nT(long double l) { return magnetic_induction(l); } // µT -constexpr auto operator"" _q_uT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_uT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_uT(long double l) { return magnetic_induction(l); } // mT -constexpr auto operator"" _q_mT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_mT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_mT(long double l) { return magnetic_induction(l); } // kT -constexpr auto operator"" _q_kT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_kT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_kT(long double l) { return magnetic_induction(l); } // MT -constexpr auto operator"" _q_MT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_MT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_MT(long double l) { return magnetic_induction(l); } // GT -constexpr auto operator"" _q_GT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_GT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_GT(long double l) { return magnetic_induction(l); } // TT -constexpr auto operator"" _q_TT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_TT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_TT(long double l) { return magnetic_induction(l); } // PT -constexpr auto operator"" _q_PT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_PT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_PT(long double l) { return magnetic_induction(l); } // ET -constexpr auto operator"" _q_ET(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_ET(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_ET(long double l) { return magnetic_induction(l); } // ZT -constexpr auto operator"" _q_ZT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_ZT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_ZT(long double l) { return magnetic_induction(l); } // YT -constexpr auto operator"" _q_YT(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_YT(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_YT(long double l) { return magnetic_induction(l); } // G -constexpr auto operator"" _q_G(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return magnetic_induction(static_cast(l)); } +constexpr auto operator"" _q_G(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return magnetic_induction(static_cast(l)); +} constexpr auto operator"" _q_G(long double l) { return magnetic_induction(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -174,33 +247,51 @@ using namespace magnetic_induction_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES -} // namespace units::isq::si +} // namespace units::isq::si #ifndef UNITS_NO_ALIASES namespace units::aliases::isq::si::inline magnetic_induction { -template using T = units::isq::si::magnetic_induction; -template using yT = units::isq::si::magnetic_induction; -template using zT = units::isq::si::magnetic_induction; -template using aT = units::isq::si::magnetic_induction; -template using fT = units::isq::si::magnetic_induction; -template using pT = units::isq::si::magnetic_induction; -template using nT = units::isq::si::magnetic_induction; -template using uT = units::isq::si::magnetic_induction; -template using mT = units::isq::si::magnetic_induction; -template using kT = units::isq::si::magnetic_induction; -template using MT = units::isq::si::magnetic_induction; -template using GT = units::isq::si::magnetic_induction; -template using TT = units::isq::si::magnetic_induction; -template using PT = units::isq::si::magnetic_induction; -template using ET = units::isq::si::magnetic_induction; -template using ZT = units::isq::si::magnetic_induction; -template using YT = units::isq::si::magnetic_induction; -template using G = units::isq::si::magnetic_induction; +template +using T = units::isq::si::magnetic_induction; +template +using yT = units::isq::si::magnetic_induction; +template +using zT = units::isq::si::magnetic_induction; +template +using aT = units::isq::si::magnetic_induction; +template +using fT = units::isq::si::magnetic_induction; +template +using pT = units::isq::si::magnetic_induction; +template +using nT = units::isq::si::magnetic_induction; +template +using uT = units::isq::si::magnetic_induction; +template +using mT = units::isq::si::magnetic_induction; +template +using kT = units::isq::si::magnetic_induction; +template +using MT = units::isq::si::magnetic_induction; +template +using GT = units::isq::si::magnetic_induction; +template +using TT = units::isq::si::magnetic_induction; +template +using PT = units::isq::si::magnetic_induction; +template +using ET = units::isq::si::magnetic_induction; +template +using ZT = units::isq::si::magnetic_induction; +template +using YT = units::isq::si::magnetic_induction; +template +using G = units::isq::si::magnetic_induction; } // namespace units::aliases::isq::si::inline magnetic_induction -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/mass.h b/src/systems/si/include/units/isq/si/mass.h index a13c4047..620381b3 100644 --- a/src/systems/si/include/units/isq/si/mass.h +++ b/src/systems/si/include/units/isq/si/mass.h @@ -78,7 +78,8 @@ struct exatonne : prefixed_alias_unit {}; struct zettatonne : prefixed_unit {}; struct yottatonne : prefixed_unit {}; -struct dalton : named_scaled_unit {}; +struct dalton : + named_scaled_unit {}; struct dim_mass : isq::dim_mass {}; @@ -90,181 +91,350 @@ using mass = quantity; inline namespace literals { // g -constexpr auto operator"" _q_g(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_g(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_g(long double l) { return mass(l); } // yg -constexpr auto operator"" _q_yg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_yg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_yg(long double l) { return mass(l); } // zg -constexpr auto operator"" _q_zg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_zg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_zg(long double l) { return mass(l); } // ag -constexpr auto operator"" _q_ag(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ag(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ag(long double l) { return mass(l); } // fg -constexpr auto operator"" _q_fg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_fg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_fg(long double l) { return mass(l); } // pg -constexpr auto operator"" _q_pg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_pg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_pg(long double l) { return mass(l); } // ng -constexpr auto operator"" _q_ng(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ng(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ng(long double l) { return mass(l); } // ug -constexpr auto operator"" _q_ug(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ug(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ug(long double l) { return mass(l); } // mg -constexpr auto operator"" _q_mg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_mg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_mg(long double l) { return mass(l); } // cg -constexpr auto operator"" _q_cg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_cg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_cg(long double l) { return mass(l); } // dg -constexpr auto operator"" _q_dg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_dg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_dg(long double l) { return mass(l); } // dag -constexpr auto operator"" _q_dag(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_dag(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_dag(long double l) { return mass(l); } // hg -constexpr auto operator"" _q_hg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_hg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_hg(long double l) { return mass(l); } // kg -constexpr auto operator"" _q_kg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_kg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_kg(long double l) { return mass(l); } // Mg -constexpr auto operator"" _q_Mg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Mg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Mg(long double l) { return mass(l); } // Gg -constexpr auto operator"" _q_Gg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Gg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Gg(long double l) { return mass(l); } // Tg -constexpr auto operator"" _q_Tg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Tg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Tg(long double l) { return mass(l); } // Pg -constexpr auto operator"" _q_Pg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Pg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Pg(long double l) { return mass(l); } // Eg -constexpr auto operator"" _q_Eg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Eg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Eg(long double l) { return mass(l); } // Zg -constexpr auto operator"" _q_Zg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Zg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Zg(long double l) { return mass(l); } // Yg -constexpr auto operator"" _q_Yg(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Yg(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Yg(long double l) { return mass(l); } // t -constexpr auto operator"" _q_t(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_t(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_t(long double l) { return mass(l); } // yt -constexpr auto operator"" _q_yt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_yt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_yt(long double l) { return mass(l); } // zt -constexpr auto operator"" _q_zt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_zt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_zt(long double l) { return mass(l); } // at -constexpr auto operator"" _q_at(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_at(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_at(long double l) { return mass(l); } // TODO Collides with foot // ft -// constexpr auto operator"" _q_ft(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } -// constexpr auto operator"" _q_ft(long double l) { return mass(l); } +// constexpr auto operator"" _q_ft(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return +// mass(static_cast(l)); } constexpr auto operator"" _q_ft(long double l) { +// return mass(l); } // pt -constexpr auto operator"" _q_pt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_pt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_pt(long double l) { return mass(l); } // nt -constexpr auto operator"" _q_nt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_nt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_nt(long double l) { return mass(l); } // ut -constexpr auto operator"" _q_ut(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ut(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ut(long double l) { return mass(l); } // mt -constexpr auto operator"" _q_mt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_mt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_mt(long double l) { return mass(l); } // ct -constexpr auto operator"" _q_ct(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ct(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ct(long double l) { return mass(l); } // dt -constexpr auto operator"" _q_dt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_dt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_dt(long double l) { return mass(l); } // dat -constexpr auto operator"" _q_dat(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_dat(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_dat(long double l) { return mass(l); } // ht -constexpr auto operator"" _q_ht(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_ht(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_ht(long double l) { return mass(l); } // kt -constexpr auto operator"" _q_kt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_kt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_kt(long double l) { return mass(l); } // Mt -constexpr auto operator"" _q_Mt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Mt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Mt(long double l) { return mass(l); } // Gt -constexpr auto operator"" _q_Gt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Gt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Gt(long double l) { return mass(l); } // Tt -constexpr auto operator"" _q_Tt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Tt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Tt(long double l) { return mass(l); } // Pt -constexpr auto operator"" _q_Pt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Pt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Pt(long double l) { return mass(l); } // Et -constexpr auto operator"" _q_Et(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Et(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Et(long double l) { return mass(l); } // Zt -constexpr auto operator"" _q_Zt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Zt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Zt(long double l) { return mass(l); } // Yt -constexpr auto operator"" _q_Yt(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Yt(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Yt(long double l) { return mass(l); } // Da -constexpr auto operator"" _q_Da(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return mass(static_cast(l)); } +constexpr auto operator"" _q_Da(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return mass(static_cast(l)); +} constexpr auto operator"" _q_Da(long double l) { return mass(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -323,7 +493,7 @@ using namespace mass_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -331,51 +501,94 @@ using namespace mass_references; namespace units::aliases::isq::si::inline mass { -template using g = units::isq::si::mass; -template using yg = units::isq::si::mass; -template using zg = units::isq::si::mass; -template using ag = units::isq::si::mass; -template using fg = units::isq::si::mass; -template using pg = units::isq::si::mass; -template using ng = units::isq::si::mass; -template using ug = units::isq::si::mass; -template using mg = units::isq::si::mass; -template using cg = units::isq::si::mass; -template using dg = units::isq::si::mass; -template using dag = units::isq::si::mass; -template using hg = units::isq::si::mass; -template using kg = units::isq::si::mass; -template using Mg = units::isq::si::mass; -template using Gg = units::isq::si::mass; -template using Tg = units::isq::si::mass; -template using Pg = units::isq::si::mass; -template using Eg = units::isq::si::mass; -template using Zg = units::isq::si::mass; -template using Yg = units::isq::si::mass; +template +using g = units::isq::si::mass; +template +using yg = units::isq::si::mass; +template +using zg = units::isq::si::mass; +template +using ag = units::isq::si::mass; +template +using fg = units::isq::si::mass; +template +using pg = units::isq::si::mass; +template +using ng = units::isq::si::mass; +template +using ug = units::isq::si::mass; +template +using mg = units::isq::si::mass; +template +using cg = units::isq::si::mass; +template +using dg = units::isq::si::mass; +template +using dag = units::isq::si::mass; +template +using hg = units::isq::si::mass; +template +using kg = units::isq::si::mass; +template +using Mg = units::isq::si::mass; +template +using Gg = units::isq::si::mass; +template +using Tg = units::isq::si::mass; +template +using Pg = units::isq::si::mass; +template +using Eg = units::isq::si::mass; +template +using Zg = units::isq::si::mass; +template +using Yg = units::isq::si::mass; -template using t = units::isq::si::mass; -template using yt = units::isq::si::mass; -template using zt = units::isq::si::mass; -template using at = units::isq::si::mass; -template using ft = units::isq::si::mass; -template using pt = units::isq::si::mass; -template using nt = units::isq::si::mass; -template using ut = units::isq::si::mass; -template using mt = units::isq::si::mass; -template using ct = units::isq::si::mass; -template using dt = units::isq::si::mass; -template using dat = units::isq::si::mass; -template using ht = units::isq::si::mass; -template using kt = units::isq::si::mass; -template using Mt = units::isq::si::mass; -template using Gt = units::isq::si::mass; -template using Tt = units::isq::si::mass; -template using Pt = units::isq::si::mass; -template using Et = units::isq::si::mass; -template using Zt = units::isq::si::mass; -template using Yt = units::isq::si::mass; -template using Da = units::isq::si::mass; +template +using t = units::isq::si::mass; +template +using yt = units::isq::si::mass; +template +using zt = units::isq::si::mass; +template +using at = units::isq::si::mass; +template +using ft = units::isq::si::mass; +template +using pt = units::isq::si::mass; +template +using nt = units::isq::si::mass; +template +using ut = units::isq::si::mass; +template +using mt = units::isq::si::mass; +template +using ct = units::isq::si::mass; +template +using dt = units::isq::si::mass; +template +using dat = units::isq::si::mass; +template +using ht = units::isq::si::mass; +template +using kt = units::isq::si::mass; +template +using Mt = units::isq::si::mass; +template +using Gt = units::isq::si::mass; +template +using Tt = units::isq::si::mass; +template +using Pt = units::isq::si::mass; +template +using Et = units::isq::si::mass; +template +using Zt = units::isq::si::mass; +template +using Yt = units::isq::si::mass; +template +using Da = units::isq::si::mass; } // namespace units::aliases::isq::si::inline mass -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/momentum.h b/src/systems/si/include/units/isq/si/momentum.h index 28151b6f..f4605e88 100644 --- a/src/systems/si/include/units/isq/si/momentum.h +++ b/src/systems/si/include/units/isq/si/momentum.h @@ -45,12 +45,16 @@ using momentum = quantity; inline namespace literals { // kg*m/s -constexpr auto operator"" _q_kg_m_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return momentum(static_cast(l)); } +constexpr auto operator"" _q_kg_m_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return momentum(static_cast(l)); +} constexpr auto operator"" _q_kg_m_per_s(long double l) { return momentum(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +62,9 @@ constexpr auto operator"" _q_kg_m_per_s(long double l) { return momentum using kg_m_per_s = units::isq::si::momentum; +template +using kg_m_per_s = units::isq::si::momentum; } // namespace units::aliases::isq::si::inline momentum -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/permeability.h b/src/systems/si/include/units/isq/si/permeability.h index 260e5658..2cb04734 100644 --- a/src/systems/si/include/units/isq/si/permeability.h +++ b/src/systems/si/include/units/isq/si/permeability.h @@ -46,12 +46,16 @@ using permeability = quantity; inline namespace literals { // H/m -constexpr auto operator"" _q_H_per_m(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return permeability(static_cast(l)); } +constexpr auto operator"" _q_H_per_m(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return permeability(static_cast(l)); +} constexpr auto operator"" _q_H_per_m(long double l) { return permeability(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -59,8 +63,9 @@ constexpr auto operator"" _q_H_per_m(long double l) { return permeability using H_per_m = units::isq::si::permeability; +template +using H_per_m = units::isq::si::permeability; } // namespace units::aliases::isq::si::inline permeability -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/permittivity.h b/src/systems/si/include/units/isq/si/permittivity.h index 850430fe..bb6b1953 100644 --- a/src/systems/si/include/units/isq/si/permittivity.h +++ b/src/systems/si/include/units/isq/si/permittivity.h @@ -46,12 +46,16 @@ using permittivity = quantity; inline namespace literals { // F/m -constexpr auto operator"" _q_F_per_m(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return permittivity(static_cast(l)); } +constexpr auto operator"" _q_F_per_m(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return permittivity(static_cast(l)); +} constexpr auto operator"" _q_F_per_m(long double l) { return permittivity(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -59,8 +63,9 @@ constexpr auto operator"" _q_F_per_m(long double l) { return permittivity using F_per_m = units::isq::si::permittivity; +template +using F_per_m = units::isq::si::permittivity; } // namespace units::aliases::isq::si::inline permittivity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/power.h b/src/systems/si/include/units/isq/si/power.h index ebe1bb03..360e92e9 100644 --- a/src/systems/si/include/units/isq/si/power.h +++ b/src/systems/si/include/units/isq/si/power.h @@ -63,76 +63,144 @@ using power = quantity; inline namespace literals { // W -constexpr auto operator"" _q_W(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_W(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_W(long double l) { return power(l); } // yW -constexpr auto operator"" _q_yW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_yW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_yW(long double l) { return power(l); } // zW -constexpr auto operator"" _q_zW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_zW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_zW(long double l) { return power(l); } // aW -constexpr auto operator"" _q_aW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_aW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_aW(long double l) { return power(l); } // fW -constexpr auto operator"" _q_fW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_fW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_fW(long double l) { return power(l); } // pW -constexpr auto operator"" _q_pW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_pW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_pW(long double l) { return power(l); } // nW -constexpr auto operator"" _q_nW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_nW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_nW(long double l) { return power(l); } // uW -constexpr auto operator"" _q_uW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_uW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_uW(long double l) { return power(l); } // mW -constexpr auto operator"" _q_mW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_mW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_mW(long double l) { return power(l); } // kW -constexpr auto operator"" _q_kW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_kW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_kW(long double l) { return power(l); } // MW -constexpr auto operator"" _q_MW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_MW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_MW(long double l) { return power(l); } // GW -constexpr auto operator"" _q_GW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_GW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_GW(long double l) { return power(l); } // TW -constexpr auto operator"" _q_TW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_TW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_TW(long double l) { return power(l); } // PW -constexpr auto operator"" _q_PW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_PW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_PW(long double l) { return power(l); } // EW -constexpr auto operator"" _q_EW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_EW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_EW(long double l) { return power(l); } // ZW -constexpr auto operator"" _q_ZW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_ZW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_ZW(long double l) { return power(l); } // YW -constexpr auto operator"" _q_YW(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return power(static_cast(l)); } +constexpr auto operator"" _q_YW(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return power(static_cast(l)); +} constexpr auto operator"" _q_YW(long double l) { return power(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -164,7 +232,7 @@ using namespace power_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -172,24 +240,41 @@ using namespace power_references; namespace units::aliases::isq::si::inline power { -template using W = units::isq::si::power; -template using yW = units::isq::si::power; -template using zW = units::isq::si::power; -template using aW = units::isq::si::power; -template using fW = units::isq::si::power; -template using pW = units::isq::si::power; -template using nW = units::isq::si::power; -template using uW = units::isq::si::power; -template using mW = units::isq::si::power; -template using kW = units::isq::si::power; -template using MW = units::isq::si::power; -template using GW = units::isq::si::power; -template using TW = units::isq::si::power; -template using PW = units::isq::si::power; -template using EW = units::isq::si::power; -template using ZW = units::isq::si::power; -template using YW = units::isq::si::power; +template +using W = units::isq::si::power; +template +using yW = units::isq::si::power; +template +using zW = units::isq::si::power; +template +using aW = units::isq::si::power; +template +using fW = units::isq::si::power; +template +using pW = units::isq::si::power; +template +using nW = units::isq::si::power; +template +using uW = units::isq::si::power; +template +using mW = units::isq::si::power; +template +using kW = units::isq::si::power; +template +using MW = units::isq::si::power; +template +using GW = units::isq::si::power; +template +using TW = units::isq::si::power; +template +using PW = units::isq::si::power; +template +using EW = units::isq::si::power; +template +using ZW = units::isq::si::power; +template +using YW = units::isq::si::power; } // namespace units::aliases::isq::si::inline power -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/resistance.h b/src/systems/si/include/units/isq/si/resistance.h index ab6a8bfa..83d3fca0 100644 --- a/src/systems/si/include/units/isq/si/resistance.h +++ b/src/systems/si/include/units/isq/si/resistance.h @@ -29,9 +29,9 @@ #include // IWYU pragma: end_exports -#include #include #include +#include #include namespace units::isq::si { @@ -64,76 +64,144 @@ using resistance = quantity; inline namespace literals { // R -constexpr auto operator"" _q_R(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_R(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_R(long double l) { return resistance(l); } // yR -constexpr auto operator"" _q_yR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_yR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_yR(long double l) { return resistance(l); } // zR -constexpr auto operator"" _q_zR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_zR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_zR(long double l) { return resistance(l); } // aR -constexpr auto operator"" _q_aR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_aR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_aR(long double l) { return resistance(l); } // fR -constexpr auto operator"" _q_fR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_fR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_fR(long double l) { return resistance(l); } // pR -constexpr auto operator"" _q_pR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_pR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_pR(long double l) { return resistance(l); } // nR -constexpr auto operator"" _q_nR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_nR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_nR(long double l) { return resistance(l); } // uR -constexpr auto operator"" _q_uR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_uR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_uR(long double l) { return resistance(l); } // mR -constexpr auto operator"" _q_mR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_mR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_mR(long double l) { return resistance(l); } // kR -constexpr auto operator"" _q_kR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_kR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_kR(long double l) { return resistance(l); } // MR -constexpr auto operator"" _q_MR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_MR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_MR(long double l) { return resistance(l); } // GR -constexpr auto operator"" _q_GR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_GR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_GR(long double l) { return resistance(l); } // TR -constexpr auto operator"" _q_TR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_TR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_TR(long double l) { return resistance(l); } // PR -constexpr auto operator"" _q_PR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_PR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_PR(long double l) { return resistance(l); } // ER -constexpr auto operator"" _q_ER(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_ER(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_ER(long double l) { return resistance(l); } // ZR -constexpr auto operator"" _q_ZR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_ZR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_ZR(long double l) { return resistance(l); } // YR -constexpr auto operator"" _q_YR(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return resistance(static_cast(l)); } +constexpr auto operator"" _q_YR(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return resistance(static_cast(l)); +} constexpr auto operator"" _q_YR(long double l) { return resistance(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -165,7 +233,7 @@ using namespace resistance_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -173,24 +241,41 @@ using namespace resistance_references; namespace units::aliases::isq::si::inline resistance { -template using R = units::isq::si::resistance; -template using yR = units::isq::si::resistance; -template using zR = units::isq::si::resistance; -template using aR = units::isq::si::resistance; -template using fR = units::isq::si::resistance; -template using pR = units::isq::si::resistance; -template using nR = units::isq::si::resistance; -template using uR = units::isq::si::resistance; -template using mR = units::isq::si::resistance; -template using kR = units::isq::si::resistance; -template using MR = units::isq::si::resistance; -template using GR = units::isq::si::resistance; -template using TR = units::isq::si::resistance; -template using PR = units::isq::si::resistance; -template using ER = units::isq::si::resistance; -template using ZR = units::isq::si::resistance; -template using YR = units::isq::si::resistance; +template +using R = units::isq::si::resistance; +template +using yR = units::isq::si::resistance; +template +using zR = units::isq::si::resistance; +template +using aR = units::isq::si::resistance; +template +using fR = units::isq::si::resistance; +template +using pR = units::isq::si::resistance; +template +using nR = units::isq::si::resistance; +template +using uR = units::isq::si::resistance; +template +using mR = units::isq::si::resistance; +template +using kR = units::isq::si::resistance; +template +using MR = units::isq::si::resistance; +template +using GR = units::isq::si::resistance; +template +using TR = units::isq::si::resistance; +template +using PR = units::isq::si::resistance; +template +using ER = units::isq::si::resistance; +template +using ZR = units::isq::si::resistance; +template +using YR = units::isq::si::resistance; } // namespace units::aliases::isq::si::inline resistance -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/si.h b/src/systems/si/include/units/isq/si/si.h index 957fa4b3..6a0d03c9 100644 --- a/src/systems/si/include/units/isq/si/si.h +++ b/src/systems/si/include/units/isq/si/si.h @@ -23,16 +23,9 @@ #pragma once // IWYU pragma: begin_exports -#include -#include -#include -#include -#include -#include -#include - #include #include +#include #include #include #include @@ -44,8 +37,14 @@ #include #include #include +#include #include #include +#include +#include +#include +#include +#include // TODO Add when downcasting issue is solved (collides with pressure) // #include #include @@ -63,6 +62,8 @@ #include // TODO Add when downcasting issue is solved (collides with frequency) // #include +#include +#include #include #include #include @@ -70,7 +71,4 @@ #include #include #include - -#include -#include // IWYU pragma: end_exports diff --git a/src/systems/si/include/units/isq/si/speed.h b/src/systems/si/include/units/isq/si/speed.h index 0405f67c..4d03d36b 100644 --- a/src/systems/si/include/units/isq/si/speed.h +++ b/src/systems/si/include/units/isq/si/speed.h @@ -47,16 +47,24 @@ using speed = quantity; inline namespace literals { // m/s -constexpr auto operator"" _q_m_per_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_m_per_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_m_per_s(long double l) { return speed(l); } // km/h -constexpr auto operator"" _q_km_per_h(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return speed(static_cast(l)); } +constexpr auto operator"" _q_km_per_h(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return speed(static_cast(l)); +} constexpr auto operator"" _q_km_per_h(long double l) { return speed(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -64,9 +72,11 @@ constexpr auto operator"" _q_km_per_h(long double l) { return speed using m_per_s = units::isq::si::speed; -template using km_per_h = units::isq::si::speed; +template +using m_per_s = units::isq::si::speed; +template +using km_per_h = units::isq::si::speed; } // namespace units::aliases::isq::si::inline speed -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/surface_tension.h b/src/systems/si/include/units/isq/si/surface_tension.h index 51754814..87b02a2c 100644 --- a/src/systems/si/include/units/isq/si/surface_tension.h +++ b/src/systems/si/include/units/isq/si/surface_tension.h @@ -45,12 +45,16 @@ using surface_tension = quantity; inline namespace literals { // N/m -constexpr auto operator"" _q_N_per_m(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return surface_tension(static_cast(l)); } +constexpr auto operator"" _q_N_per_m(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return surface_tension(static_cast(l)); +} constexpr auto operator"" _q_N_per_m(long double l) { return surface_tension(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -58,8 +62,9 @@ constexpr auto operator"" _q_N_per_m(long double l) { return surface_tension using N_per_m = units::isq::si::surface_tension; +template +using N_per_m = units::isq::si::surface_tension; } // namespace units::aliases::isq::si::inline surface_tension -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/thermal_conductivity.h b/src/systems/si/include/units/isq/si/thermal_conductivity.h index eab781db..d4a09c9f 100644 --- a/src/systems/si/include/units/isq/si/thermal_conductivity.h +++ b/src/systems/si/include/units/isq/si/thermal_conductivity.h @@ -36,7 +36,9 @@ namespace units::isq::si { struct watt_per_metre_kelvin : unit {}; -struct dim_thermal_conductivity : isq::dim_thermal_conductivity {}; +struct dim_thermal_conductivity : + isq::dim_thermal_conductivity {}; template U, Representation Rep = double> using thermal_conductivity = quantity; @@ -46,12 +48,19 @@ using thermal_conductivity = quantity; inline namespace literals { // W/(m K) -constexpr auto operator"" _q_W_per_m_K(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return thermal_conductivity(static_cast(l)); } -constexpr auto operator"" _q_W_per_m_K(long double l) { return thermal_conductivity(l); } +constexpr auto operator"" _q_W_per_m_K(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return thermal_conductivity(static_cast(l)); +} +constexpr auto operator"" _q_W_per_m_K(long double l) +{ + return thermal_conductivity(l); +} } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -59,8 +68,9 @@ constexpr auto operator"" _q_W_per_m_K(long double l) { return thermal_conductiv namespace units::aliases::isq::si::inline thermal_conductivity { -template using W_per_m_K = units::isq::si::thermal_conductivity; +template +using W_per_m_K = units::isq::si::thermal_conductivity; } // namespace units::aliases::isq::si::inline thermal_conductivity -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h index 10ee923b..8989ca8d 100644 --- a/src/systems/si/include/units/isq/si/thermodynamic_temperature.h +++ b/src/systems/si/include/units/isq/si/thermodynamic_temperature.h @@ -45,12 +45,16 @@ using thermodynamic_temperature = quantity(l)); return thermodynamic_temperature(static_cast(l)); } +constexpr auto operator"" _q_K(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return thermodynamic_temperature(static_cast(l)); +} constexpr auto operator"" _q_K(long double l) { return thermodynamic_temperature(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -66,7 +70,7 @@ using namespace thermodynamic_temperature_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -74,8 +78,9 @@ using namespace thermodynamic_temperature_references; namespace units::aliases::isq::si::inline thermodynamic_temperature { -template using K = units::isq::si::thermodynamic_temperature; +template +using K = units::isq::si::thermodynamic_temperature; } // namespace units::aliases::isq::si::inline thermodynamic_temperature -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/time.h b/src/systems/si/include/units/isq/si/time.h index ebcd163e..7c1d4d5c 100644 --- a/src/systems/si/include/units/isq/si/time.h +++ b/src/systems/si/include/units/isq/si/time.h @@ -57,56 +57,104 @@ using time = quantity; inline namespace literals { // ys -constexpr auto operator"" _q_ys(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_ys(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_ys(long double l) { return time(l); } // zs -constexpr auto operator"" _q_zs(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_zs(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_zs(long double l) { return time(l); } // as -constexpr auto operator"" _q_as(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_as(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_as(long double l) { return time(l); } // fs -constexpr auto operator"" _q_fs(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_fs(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_fs(long double l) { return time(l); } // ps -constexpr auto operator"" _q_ps(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_ps(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_ps(long double l) { return time(l); } // ns -constexpr auto operator"" _q_ns(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_ns(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_ns(long double l) { return time(l); } // us -constexpr auto operator"" _q_us(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_us(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_us(long double l) { return time(l); } // ms -constexpr auto operator"" _q_ms(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_ms(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_ms(long double l) { return time(l); } // s -constexpr auto operator"" _q_s(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_s(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_s(long double l) { return time(l); } // min -constexpr auto operator"" _q_min(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_min(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_min(long double l) { return time(l); } // h -constexpr auto operator"" _q_h(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_h(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_h(long double l) { return time(l); } // d -constexpr auto operator"" _q_d(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return time(static_cast(l)); } +constexpr auto operator"" _q_d(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return time(static_cast(l)); +} constexpr auto operator"" _q_d(long double l) { return time(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -131,9 +179,9 @@ namespace references { using namespace time_references; -} // namespace references +} // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -141,19 +189,31 @@ using namespace time_references; namespace units::aliases::isq::si::inline time { -template using ys = units::isq::si::time; -template using zs = units::isq::si::time; -template using as = units::isq::si::time; -template using fs = units::isq::si::time; -template using ps = units::isq::si::time; -template using ns = units::isq::si::time; -template using us = units::isq::si::time; -template using ms = units::isq::si::time; -template using s = units::isq::si::time; -template using min = units::isq::si::time; -template using h = units::isq::si::time; -template using d = units::isq::si::time; +template +using ys = units::isq::si::time; +template +using zs = units::isq::si::time; +template +using as = units::isq::si::time; +template +using fs = units::isq::si::time; +template +using ps = units::isq::si::time; +template +using ns = units::isq::si::time; +template +using us = units::isq::si::time; +template +using ms = units::isq::si::time; +template +using s = units::isq::si::time; +template +using min = units::isq::si::time; +template +using h = units::isq::si::time; +template +using d = units::isq::si::time; } // namespace units::aliases::isq::si::inline time -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/torque.h b/src/systems/si/include/units/isq/si/torque.h index 411f2d81..1245cf6c 100644 --- a/src/systems/si/include/units/isq/si/torque.h +++ b/src/systems/si/include/units/isq/si/torque.h @@ -28,8 +28,8 @@ #include // IWYU pragma: end_exports -#include #include +#include #include #include @@ -47,12 +47,16 @@ using torque = quantity; inline namespace literals { // Nm -constexpr auto operator"" _q_N_m_per_rad(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return torque(static_cast(l)); } +constexpr auto operator"" _q_N_m_per_rad(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return torque(static_cast(l)); +} constexpr auto operator"" _q_N_m_per_rad(long double l) { return torque(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS } // namespace units::isq::si @@ -60,8 +64,9 @@ constexpr auto operator"" _q_N_m_per_rad(long double l) { return torque using N_m_per_rad = units::isq::si::torque; +template +using N_m_per_rad = units::isq::si::torque; } // namespace units::aliases::isq::si::inline torque -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/src/systems/si/include/units/isq/si/volume.h b/src/systems/si/include/units/isq/si/volume.h index 4d328bcf..8430e60b 100644 --- a/src/systems/si/include/units/isq/si/volume.h +++ b/src/systems/si/include/units/isq/si/volume.h @@ -88,176 +88,344 @@ using volume = quantity; inline namespace literals { // m3 -constexpr auto operator"" _q_m3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_m3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_m3(long double l) { return volume(l); } // ym3 -constexpr auto operator"" _q_ym3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_ym3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_ym3(long double l) { return volume(l); } // zm3 -constexpr auto operator"" _q_zm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_zm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_zm3(long double l) { return volume(l); } // am3 -constexpr auto operator"" _q_am3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_am3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_am3(long double l) { return volume(l); } // fm3 -constexpr auto operator"" _q_fm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_fm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_fm3(long double l) { return volume(l); } // pm3 -constexpr auto operator"" _q_pm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_pm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_pm3(long double l) { return volume(l); } // nm3 -constexpr auto operator"" _q_nm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_nm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_nm3(long double l) { return volume(l); } // um3 -constexpr auto operator"" _q_um3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_um3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_um3(long double l) { return volume(l); } // mm3 -constexpr auto operator"" _q_mm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_mm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_mm3(long double l) { return volume(l); } // cm3 -constexpr auto operator"" _q_cm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_cm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_cm3(long double l) { return volume(l); } // dm3 -constexpr auto operator"" _q_dm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_dm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_dm3(long double l) { return volume(l); } // dam3 -constexpr auto operator"" _q_dam3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_dam3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_dam3(long double l) { return volume(l); } // hm3 -constexpr auto operator"" _q_hm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_hm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_hm3(long double l) { return volume(l); } // km3 -constexpr auto operator"" _q_km3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_km3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_km3(long double l) { return volume(l); } // Mm3 -constexpr auto operator"" _q_Mm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Mm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Mm3(long double l) { return volume(l); } // Gm3 -constexpr auto operator"" _q_Gm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Gm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Gm3(long double l) { return volume(l); } // Tm3 -constexpr auto operator"" _q_Tm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Tm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Tm3(long double l) { return volume(l); } // Pm3 -constexpr auto operator"" _q_Pm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Pm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Pm3(long double l) { return volume(l); } // Em3 -constexpr auto operator"" _q_Em3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Em3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Em3(long double l) { return volume(l); } // Zm3 -constexpr auto operator"" _q_Zm3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Zm3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Zm3(long double l) { return volume(l); } // Ym3 -constexpr auto operator"" _q_Ym3(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Ym3(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Ym3(long double l) { return volume(l); } // l -constexpr auto operator"" _q_l(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_l(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_l(long double l) { return volume(l); } // yl -constexpr auto operator"" _q_yl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_yl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_yl(long double l) { return volume(l); } // zl -constexpr auto operator"" _q_zl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_zl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_zl(long double l) { return volume(l); } // al -constexpr auto operator"" _q_al(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_al(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_al(long double l) { return volume(l); } // fl -constexpr auto operator"" _q_fl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_fl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_fl(long double l) { return volume(l); } // pl -constexpr auto operator"" _q_pl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_pl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_pl(long double l) { return volume(l); } // nl -constexpr auto operator"" _q_nl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_nl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_nl(long double l) { return volume(l); } // ul -constexpr auto operator"" _q_ul(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_ul(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_ul(long double l) { return volume(l); } // ml -constexpr auto operator"" _q_ml(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_ml(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_ml(long double l) { return volume(l); } // cl -constexpr auto operator"" _q_cl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_cl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_cl(long double l) { return volume(l); } // dl -constexpr auto operator"" _q_dl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_dl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_dl(long double l) { return volume(l); } // dal -constexpr auto operator"" _q_dal(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_dal(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_dal(long double l) { return volume(l); } // hl -constexpr auto operator"" _q_hl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_hl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_hl(long double l) { return volume(l); } // kl -constexpr auto operator"" _q_kl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_kl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_kl(long double l) { return volume(l); } // Ml -constexpr auto operator"" _q_Ml(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Ml(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Ml(long double l) { return volume(l); } // Gl -constexpr auto operator"" _q_Gl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Gl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Gl(long double l) { return volume(l); } // Tl -constexpr auto operator"" _q_Tl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Tl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Tl(long double l) { return volume(l); } // Pl -constexpr auto operator"" _q_Pl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Pl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Pl(long double l) { return volume(l); } // El -constexpr auto operator"" _q_El(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_El(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_El(long double l) { return volume(l); } // Zl -constexpr auto operator"" _q_Zl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Zl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Zl(long double l) { return volume(l); } // Yl -constexpr auto operator"" _q_Yl(unsigned long long l) { gsl_ExpectsAudit(std::in_range(l)); return volume(static_cast(l)); } +constexpr auto operator"" _q_Yl(unsigned long long l) +{ + gsl_ExpectsAudit(std::in_range(l)); + return volume(static_cast(l)); +} constexpr auto operator"" _q_Yl(long double l) { return volume(l); } } // namespace literals -#endif // UNITS_NO_LITERALS +#endif // UNITS_NO_LITERALS #ifndef UNITS_NO_REFERENCES @@ -315,7 +483,7 @@ using namespace volume_references; } // namespace references -#endif // UNITS_NO_REFERENCES +#endif // UNITS_NO_REFERENCES } // namespace units::isq::si @@ -323,50 +491,92 @@ using namespace volume_references; namespace units::aliases::isq::si::inline volume { -template using m3 = units::isq::si::volume; -template using ym3 = units::isq::si::volume; -template using zm3 = units::isq::si::volume; -template using am3 = units::isq::si::volume; -template using fm3 = units::isq::si::volume; -template using pm3 = units::isq::si::volume; -template using nm3 = units::isq::si::volume; -template using um3 = units::isq::si::volume; -template using mm3 = units::isq::si::volume; -template using cm3 = units::isq::si::volume; -template using dm3 = units::isq::si::volume; -template using dam3 = units::isq::si::volume; -template using hm3 = units::isq::si::volume; -template using km3 = units::isq::si::volume; -template using Mm3 = units::isq::si::volume; -template using Gm3 = units::isq::si::volume; -template using Tm3 = units::isq::si::volume; -template using Pm3 = units::isq::si::volume; -template using Em3 = units::isq::si::volume; -template using Zm3 = units::isq::si::volume; -template using Ym3 = units::isq::si::volume; +template +using m3 = units::isq::si::volume; +template +using ym3 = units::isq::si::volume; +template +using zm3 = units::isq::si::volume; +template +using am3 = units::isq::si::volume; +template +using fm3 = units::isq::si::volume; +template +using pm3 = units::isq::si::volume; +template +using nm3 = units::isq::si::volume; +template +using um3 = units::isq::si::volume; +template +using mm3 = units::isq::si::volume; +template +using cm3 = units::isq::si::volume; +template +using dm3 = units::isq::si::volume; +template +using dam3 = units::isq::si::volume; +template +using hm3 = units::isq::si::volume; +template +using km3 = units::isq::si::volume; +template +using Mm3 = units::isq::si::volume; +template +using Gm3 = units::isq::si::volume; +template +using Tm3 = units::isq::si::volume; +template +using Pm3 = units::isq::si::volume; +template +using Em3 = units::isq::si::volume; +template +using Zm3 = units::isq::si::volume; +template +using Ym3 = units::isq::si::volume; -template using l = units::isq::si::volume; -template using yl = units::isq::si::volume; -template using zl = units::isq::si::volume; -template using al = units::isq::si::volume; -template using fl = units::isq::si::volume; -template using pl = units::isq::si::volume; -template using nl = units::isq::si::volume; -template using ul = units::isq::si::volume; -template using ml = units::isq::si::volume; -template using cl = units::isq::si::volume; -template using dl = units::isq::si::volume; -template using dal = units::isq::si::volume; -template using hl = units::isq::si::volume; -template using kl = units::isq::si::volume; -template using Ml = units::isq::si::volume; -template using Gl = units::isq::si::volume; -template using Tl = units::isq::si::volume; -template using Pl = units::isq::si::volume; -template using El = units::isq::si::volume; -template using Zl = units::isq::si::volume; -template using Yl = units::isq::si::volume; +template +using l = units::isq::si::volume; +template +using yl = units::isq::si::volume; +template +using zl = units::isq::si::volume; +template +using al = units::isq::si::volume; +template +using fl = units::isq::si::volume; +template +using pl = units::isq::si::volume; +template +using nl = units::isq::si::volume; +template +using ul = units::isq::si::volume; +template +using ml = units::isq::si::volume; +template +using cl = units::isq::si::volume; +template +using dl = units::isq::si::volume; +template +using dal = units::isq::si::volume; +template +using hl = units::isq::si::volume; +template +using kl = units::isq::si::volume; +template +using Ml = units::isq::si::volume; +template +using Gl = units::isq::si::volume; +template +using Tl = units::isq::si::volume; +template +using Pl = units::isq::si::volume; +template +using El = units::isq::si::volume; +template +using Zl = units::isq::si::volume; +template +using Yl = units::isq::si::volume; } // namespace units::aliases::isq::si::inline volume -#endif // UNITS_NO_ALIASES +#endif // UNITS_NO_ALIASES diff --git a/test/unit_test/runtime/distribution_test.cpp b/test/unit_test/runtime/distribution_test.cpp index c1c58a26..e5dda8e6 100644 --- a/test/unit_test/runtime/distribution_test.cpp +++ b/test/unit_test/runtime/distribution_test.cpp @@ -20,10 +20,10 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include -#include -#include #include +#include +#include +#include #include #include #include @@ -39,16 +39,17 @@ TEST_CASE("uniform_int_distribution") SECTION("default") { - auto dist = units::uniform_int_distribution(); - - CHECK(dist.a() == q::zero()); - CHECK(dist.b() == q::max()); + auto dist = units::uniform_int_distribution(); + + CHECK(dist.a() == q::zero()); + CHECK(dist.b() == q::max()); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep a = 2; constexpr rep b = 5; - + auto stl_dist = std::uniform_int_distribution(a, b); auto units_dist = units::uniform_int_distribution(q(a), q(b)); @@ -66,16 +67,17 @@ TEST_CASE("uniform_real_distribution") SECTION("default") { - auto dist = units::uniform_real_distribution(); - - CHECK(dist.a() == q::zero()); - CHECK(dist.b() == q::one()); + auto dist = units::uniform_real_distribution(); + + CHECK(dist.a() == q::zero()); + CHECK(dist.b() == q::one()); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep a = 2.0; constexpr rep b = 5.0; - + auto stl_dist = std::uniform_real_distribution(a, b); auto units_dist = units::uniform_real_distribution(q(a), q(b)); @@ -93,16 +95,17 @@ TEST_CASE("binomial_distribution") SECTION("default") { - auto dist = units::binomial_distribution(); - - CHECK(dist.p() == 0.5); - CHECK(dist.t() == q::one()); + auto dist = units::binomial_distribution(); + + CHECK(dist.p() == 0.5); + CHECK(dist.t() == q::one()); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep t = 5; constexpr double p = 0.25; - + auto stl_dist = std::binomial_distribution(t, p); auto units_dist = units::binomial_distribution(q(t), p); @@ -120,16 +123,17 @@ TEST_CASE("negative_binomial_distribution") SECTION("default") { - auto dist = units::negative_binomial_distribution(); - - CHECK(dist.p() == 0.5); - CHECK(dist.k() == q::one()); + auto dist = units::negative_binomial_distribution(); + + CHECK(dist.p() == 0.5); + CHECK(dist.k() == q::one()); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep k = 5; constexpr double p = 0.25; - + auto stl_dist = std::negative_binomial_distribution(k, p); auto units_dist = units::negative_binomial_distribution(q(k), p); @@ -147,14 +151,15 @@ TEST_CASE("geometric_distribution") SECTION("default") { - auto dist = units::geometric_distribution(); - - CHECK(dist.p() == 0.5); + auto dist = units::geometric_distribution(); + + CHECK(dist.p() == 0.5); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr double p = 0.25; - + auto stl_dist = std::geometric_distribution(p); auto units_dist = units::geometric_distribution(p); @@ -171,14 +176,15 @@ TEST_CASE("poisson_distribution") SECTION("default") { - auto dist = units::poisson_distribution(); - - CHECK(dist.mean() == 1.0); + auto dist = units::poisson_distribution(); + + CHECK(dist.mean() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr double mean = 5.0; - + auto stl_dist = std::poisson_distribution(mean); auto units_dist = units::poisson_distribution(mean); @@ -195,14 +201,15 @@ TEST_CASE("exponential_distribution") SECTION("default") { - auto dist = units::exponential_distribution(); - - CHECK(dist.lambda() == 1.0); + auto dist = units::exponential_distribution(); + + CHECK(dist.lambda() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr double lambda = 2.0; - + auto stl_dist = std::exponential_distribution(lambda); auto units_dist = units::exponential_distribution(lambda); @@ -219,16 +226,17 @@ TEST_CASE("gamma_distribution") SECTION("default") { - auto dist = units::gamma_distribution(); - - CHECK(dist.alpha() == 1.0); - CHECK(dist.beta() == 1.0); + auto dist = units::gamma_distribution(); + + CHECK(dist.alpha() == 1.0); + CHECK(dist.beta() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr double alpha = 5.0; constexpr double beta = 2.0; - + auto stl_dist = std::gamma_distribution(alpha, beta); auto units_dist = units::gamma_distribution(alpha, beta); @@ -246,16 +254,17 @@ TEST_CASE("weibull_distribution") SECTION("default") { - auto dist = units::weibull_distribution(); - - CHECK(dist.a() == 1.0); - CHECK(dist.b() == 1.0); + auto dist = units::weibull_distribution(); + + CHECK(dist.a() == 1.0); + CHECK(dist.b() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep a = 5.0; constexpr rep b = 2.0; - + auto stl_dist = std::weibull_distribution(a, b); auto units_dist = units::weibull_distribution(a, b); @@ -273,16 +282,17 @@ TEST_CASE("extreme_value_distribution") SECTION("default") { - auto dist = units::extreme_value_distribution(); - - CHECK(dist.a() == q::zero()); - CHECK(dist.b() == 1.0); + auto dist = units::extreme_value_distribution(); + + CHECK(dist.a() == q::zero()); + CHECK(dist.b() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep a = 5.0; constexpr rep b = 2.0; - + auto stl_dist = std::extreme_value_distribution(a, b); auto units_dist = units::extreme_value_distribution(q(a), b); @@ -300,20 +310,20 @@ TEST_CASE("normal_distribution") SECTION("default") { - auto dist = units::normal_distribution(); - - CHECK(dist.mean() == q::zero()); - CHECK(dist.stddev() == q::one()); + auto dist = units::normal_distribution(); + + CHECK(dist.mean() == q::zero()); + CHECK(dist.stddev() == q::one()); } SECTION("parametrized") { constexpr rep mean = 5.0; constexpr rep stddev = 2.0; - + auto stl_dist = std::normal_distribution(mean, stddev); auto units_dist = units::normal_distribution(q(mean), q(stddev)); - + CHECK(units_dist.mean() == q(stl_dist.mean())); CHECK(units_dist.stddev() == q(stl_dist.stddev())); CHECK(units_dist.min() == q(stl_dist.min())); @@ -328,20 +338,20 @@ TEST_CASE("lognormal_distribution") SECTION("default") { - auto dist = units::lognormal_distribution(); - - CHECK(dist.m() == q::zero()); - CHECK(dist.s() == q::one()); + auto dist = units::lognormal_distribution(); + + CHECK(dist.m() == q::zero()); + CHECK(dist.s() == q::one()); } SECTION("parametrized") { constexpr rep m = 5.0; constexpr rep s = 2.0; - + auto stl_dist = std::lognormal_distribution(m, s); auto units_dist = units::lognormal_distribution(q(m), q(s)); - + CHECK(units_dist.m() == q(stl_dist.m())); CHECK(units_dist.s() == q(stl_dist.s())); CHECK(units_dist.min() == q(stl_dist.min())); @@ -356,18 +366,18 @@ TEST_CASE("chi_squared_distribution") SECTION("default") { - auto dist = units::chi_squared_distribution(); - - CHECK(dist.n() == 1.0); + auto dist = units::chi_squared_distribution(); + + CHECK(dist.n() == 1.0); } SECTION("parametrized") { constexpr rep n = 5.0; - + auto stl_dist = std::chi_squared_distribution(n); auto units_dist = units::chi_squared_distribution(n); - + CHECK(units_dist.n() == stl_dist.n()); CHECK(units_dist.min() == q(stl_dist.min())); CHECK(units_dist.max() == q(stl_dist.max())); @@ -381,16 +391,17 @@ TEST_CASE("cauchy_distribution") SECTION("default") { - auto dist = units::cauchy_distribution(); - - CHECK(dist.a() == q::zero()); - CHECK(dist.b() == q::one()); + auto dist = units::cauchy_distribution(); + + CHECK(dist.a() == q::zero()); + CHECK(dist.b() == q::one()); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep a = 5.0; constexpr rep b = 2.0; - + auto stl_dist = std::cauchy_distribution(a, b); auto units_dist = units::cauchy_distribution(q(a), q(b)); @@ -408,16 +419,17 @@ TEST_CASE("fisher_f_distribution") SECTION("default") { - auto dist = units::fisher_f_distribution(); - - CHECK(dist.m() == 1.0); - CHECK(dist.n() == 1.0); + auto dist = units::fisher_f_distribution(); + + CHECK(dist.m() == 1.0); + CHECK(dist.n() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep m = 5.0; constexpr rep n = 2.0; - + auto stl_dist = std::fisher_f_distribution(m, n); auto units_dist = units::fisher_f_distribution(m, n); @@ -435,14 +447,15 @@ TEST_CASE("student_t_distribution") SECTION("default") { - auto dist = units::student_t_distribution(); - - CHECK(dist.n() == 1.0); + auto dist = units::student_t_distribution(); + + CHECK(dist.n() == 1.0); } - - SECTION ("parametrized") { + + SECTION("parametrized") + { constexpr rep n = 2.0; - + auto stl_dist = std::student_t_distribution(n); auto units_dist = units::student_t_distribution(n); @@ -459,36 +472,39 @@ TEST_CASE("discrete_distribution") SECTION("default") { - auto stl_dist = std::discrete_distribution(); - auto units_dist = units::discrete_distribution(); - - CHECK(units_dist.min() == q(stl_dist.min())); - CHECK(units_dist.max() == q(stl_dist.max())); - CHECK(units_dist.probabilities() == stl_dist.probabilities()); + auto stl_dist = std::discrete_distribution(); + auto units_dist = units::discrete_distribution(); + + CHECK(units_dist.min() == q(stl_dist.min())); + CHECK(units_dist.max() == q(stl_dist.max())); + CHECK(units_dist.probabilities() == stl_dist.probabilities()); } - - SECTION ("parametrized_input_it") { + + SECTION("parametrized_input_it") + { constexpr std::array weights = {1.0, 2.0, 3.0}; - + auto stl_dist = std::discrete_distribution(weights.cbegin(), weights.cend()); auto units_dist = units::discrete_distribution(weights.cbegin(), weights.cend()); CHECK(units_dist.probabilities() == stl_dist.probabilities()); } - SECTION ("parametrized_initializer_list") { + SECTION("parametrized_initializer_list") + { std::initializer_list weights = {1.0, 2.0, 3.0}; - + auto stl_dist = std::discrete_distribution(weights); auto units_dist = units::discrete_distribution(weights); CHECK(units_dist.probabilities() == stl_dist.probabilities()); } - SECTION ("parametrized_range") { + SECTION("parametrized_range") + { constexpr std::size_t count = 3; constexpr double xmin = 1, xmax = 3; - + auto stl_dist = std::discrete_distribution(count, xmin, xmax, [](double val) { return val; }); auto units_dist = units::discrete_distribution(count, xmin, xmax, [](double val) { return val; }); @@ -506,34 +522,38 @@ TEST_CASE("piecewise_constant_distribution") SECTION("default") { - auto stl_dist = std::piecewise_constant_distribution(); - auto units_dist = units::piecewise_constant_distribution(); - - CHECK(units_dist.min() == q(stl_dist.min())); - CHECK(units_dist.max() == q(stl_dist.max())); - CHECK(stl_dist.intervals().size() == 2); - CHECK(units_dist.intervals().size() == 2); - CHECK(stl_dist.densities().size() == 1); - CHECK(units_dist.densities().size() == 1); + auto stl_dist = std::piecewise_constant_distribution(); + auto units_dist = units::piecewise_constant_distribution(); + + CHECK(units_dist.min() == q(stl_dist.min())); + CHECK(units_dist.max() == q(stl_dist.max())); + CHECK(stl_dist.intervals().size() == 2); + CHECK(units_dist.intervals().size() == 2); + CHECK(stl_dist.densities().size() == 1); + CHECK(units_dist.densities().size() == 1); } - - SECTION ("parametrized_input_it") { + + SECTION("parametrized_input_it") + { constexpr std::array intervals_rep = {1.0, 2.0, 3.0}; constexpr std::array intervals_qty = {1.0_q_m, 2.0_q_m, 3.0_q_m}; constexpr std::array weights = {1.0, 2.0, 3.0}; - - auto stl_dist = std::piecewise_constant_distribution(intervals_rep.cbegin(), intervals_rep.cend(), weights.cbegin()); - auto units_dist = units::piecewise_constant_distribution(intervals_qty.cbegin(), intervals_qty.cend(), weights.cbegin()); + + auto stl_dist = + std::piecewise_constant_distribution(intervals_rep.cbegin(), intervals_rep.cend(), weights.cbegin()); + auto units_dist = + units::piecewise_constant_distribution(intervals_qty.cbegin(), intervals_qty.cend(), weights.cbegin()); CHECK(stl_dist.intervals() == intervals_rep_vec); CHECK(units_dist.intervals() == intervals_qty_vec); CHECK(units_dist.densities() == stl_dist.densities()); } - SECTION ("parametrized_initializer_list") { + SECTION("parametrized_initializer_list") + { std::initializer_list intervals_rep = {1.0, 2.0, 3.0}; std::initializer_list intervals_qty = {1.0_q_m, 2.0_q_m, 3.0_q_m}; - + auto stl_dist = std::piecewise_constant_distribution(intervals_rep, [](rep val) { return val; }); auto units_dist = units::piecewise_constant_distribution(intervals_qty, [](q qty) { return qty.number(); }); @@ -541,13 +561,15 @@ TEST_CASE("piecewise_constant_distribution") CHECK(units_dist.densities() == stl_dist.densities()); } - SECTION ("parametrized_range") { + SECTION("parametrized_range") + { constexpr std::size_t nw = 2; constexpr rep xmin_rep = 1.0, xmax_rep = 3.0; constexpr q xmin_qty = 1.0_q_m, xmax_qty = 3.0_q_m; - + auto stl_dist = std::piecewise_constant_distribution(nw, xmin_rep, xmax_rep, [](rep val) { return val; }); - auto units_dist = units::piecewise_constant_distribution(nw, xmin_qty, xmax_qty, [](q qty) { return qty.number(); }); + auto units_dist = + units::piecewise_constant_distribution(nw, xmin_qty, xmax_qty, [](q qty) { return qty.number(); }); CHECK(units_dist.intervals() == intervals_qty_vec); CHECK(units_dist.densities() == stl_dist.densities()); @@ -564,34 +586,38 @@ TEST_CASE("piecewise_linear_distribution") SECTION("default") { - auto stl_dist = std::piecewise_linear_distribution(); - auto units_dist = units::piecewise_linear_distribution(); - - CHECK(units_dist.min() == q(stl_dist.min())); - CHECK(units_dist.max() == q(stl_dist.max())); - CHECK(stl_dist.intervals().size() == 2); - CHECK(units_dist.intervals().size() == 2); - CHECK(stl_dist.densities().size() == 2); - CHECK(units_dist.densities().size() == 2); + auto stl_dist = std::piecewise_linear_distribution(); + auto units_dist = units::piecewise_linear_distribution(); + + CHECK(units_dist.min() == q(stl_dist.min())); + CHECK(units_dist.max() == q(stl_dist.max())); + CHECK(stl_dist.intervals().size() == 2); + CHECK(units_dist.intervals().size() == 2); + CHECK(stl_dist.densities().size() == 2); + CHECK(units_dist.densities().size() == 2); } - - SECTION ("parametrized_input_it") { + + SECTION("parametrized_input_it") + { constexpr std::array intervals_rep = {1.0, 2.0, 3.0}; constexpr std::array intervals_qty = {1.0_q_m, 2.0_q_m, 3.0_q_m}; constexpr std::array weights = {1.0, 2.0, 3.0}; - - auto stl_dist = std::piecewise_linear_distribution(intervals_rep.cbegin(), intervals_rep.cend(), weights.cbegin()); - auto units_dist = units::piecewise_linear_distribution(intervals_qty.cbegin(), intervals_qty.cend(), weights.cbegin()); + + auto stl_dist = + std::piecewise_linear_distribution(intervals_rep.cbegin(), intervals_rep.cend(), weights.cbegin()); + auto units_dist = + units::piecewise_linear_distribution(intervals_qty.cbegin(), intervals_qty.cend(), weights.cbegin()); CHECK(stl_dist.intervals() == intervals_rep_vec); CHECK(units_dist.intervals() == intervals_qty_vec); CHECK(units_dist.densities() == stl_dist.densities()); } - SECTION ("parametrized_initializer_list") { + SECTION("parametrized_initializer_list") + { std::initializer_list intervals_rep = {1.0, 2.0, 3.0}; std::initializer_list intervals_qty = {1.0_q_m, 2.0_q_m, 3.0_q_m}; - + auto stl_dist = std::piecewise_linear_distribution(intervals_rep, [](rep val) { return val; }); auto units_dist = units::piecewise_linear_distribution(intervals_qty, [](q qty) { return qty.number(); }); @@ -599,13 +625,15 @@ TEST_CASE("piecewise_linear_distribution") CHECK(units_dist.densities() == stl_dist.densities()); } - SECTION ("parametrized_range") { + SECTION("parametrized_range") + { constexpr std::size_t nw = 2; constexpr rep xmin_rep = 1.0, xmax_rep = 3.0; constexpr q xmin_qty = 1.0_q_m, xmax_qty = 3.0_q_m; - + auto stl_dist = std::piecewise_linear_distribution(nw, xmin_rep, xmax_rep, [](rep val) { return val; }); - auto units_dist = units::piecewise_linear_distribution(nw, xmin_qty, xmax_qty, [](q qty) { return qty.number(); }); + auto units_dist = + units::piecewise_linear_distribution(nw, xmin_qty, xmax_qty, [](q qty) { return qty.number(); }); CHECK(units_dist.intervals() == intervals_qty_vec); CHECK(units_dist.densities() == stl_dist.densities()); diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index 98496673..abc595e6 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -20,14 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include #include #include #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include #include #include #include @@ -48,20 +48,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 60_q_W; os << q; - SECTION("iostream") - { - CHECK(os.str() == "60 W"); - } + SECTION("iostream") { CHECK(os.str() == "60 W"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("floating-point representation") @@ -69,20 +60,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 1023.5_q_Pa; os << q; - SECTION("iostream") - { - CHECK(os.str() == "1023.5 Pa"); - } + SECTION("iostream") { CHECK(os.str() == "1023.5 Pa"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -91,20 +73,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 125_q_us; os << q; - SECTION("iostream") - { - CHECK(os.str() == "125 µs"); - } + SECTION("iostream") { CHECK(os.str() == "125 µs"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("quantity with a predefined unit + prefix") @@ -114,20 +87,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const length> q(123); os << q; - SECTION("iostream") - { - CHECK(os.str() == "123 Mm"); - } + SECTION("iostream") { CHECK(os.str() == "123 Mm"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("in terms of derived units") @@ -135,20 +99,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const energy> q(60); os << q; - SECTION("iostream") - { - CHECK(os.str() == "60 cJ"); - } + SECTION("iostream") { CHECK(os.str() == "60 cJ"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -157,20 +112,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_l; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 l"); - } + SECTION("iostream") { CHECK(os.str() == "2 l"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("quantity with a prefixed alias unit") @@ -178,20 +124,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_ml; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 ml"); - } + SECTION("iostream") { CHECK(os.str() == "2 ml"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("quantity with a derived unit") @@ -203,20 +140,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 20_q_m / 2_q_s / 1_q_s; os << q; - SECTION("iostream") - { - CHECK(os.str() == "10 m/s²"); - } + SECTION("iostream") { CHECK(os.str() == "10 m/s²"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("volume") @@ -224,20 +152,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_m * 1_q_m * 1_q_m; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 m³"); - } + SECTION("iostream") { CHECK(os.str() == "2 m³"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("surface tension") @@ -245,20 +164,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 20_q_N / 2_q_m; os << q; - SECTION("iostream") - { - CHECK(os.str() == "10 N/m"); - } + SECTION("iostream") { CHECK(os.str() == "10 N/m"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -269,42 +179,25 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 20_q_km / 2_q_h; os << q; - SECTION("iostream") - { - CHECK(os.str() == "10 km/h"); - } + SECTION("iostream") { CHECK(os.str() == "10 km/h"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("surface tension") { - struct newton_per_centimetre : derived_unit {}; + struct newton_per_centimetre : + derived_unit {}; const surface_tension q(123); os << q; - SECTION("iostream") - { - CHECK(os.str() == "123 N/cm"); - } + SECTION("iostream") { CHECK(os.str() == "123 N/cm"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } } @@ -316,20 +209,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_N * 2_q_cm; os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 cJ"); - } + SECTION("iostream") { CHECK(os.str() == "8 cJ"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio for a dimension without a special symbol") @@ -337,20 +221,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_um * 2_q_cm * 2_q_cm; os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 × 10⁻¹⁰ m³"); - } + SECTION("iostream") { CHECK(os.str() == "8 × 10⁻¹⁰ m³"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num != 1 && unit::ratio::den == 1") @@ -358,20 +233,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4 * 2_q_min / (2_q_s * 2_q_s); os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 [6 × 10¹] Hz"); - } + SECTION("iostream") { CHECK(os.str() == "2 [6 × 10¹] Hz"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num == 1 && unit::ratio::den != 1") @@ -379,20 +245,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 20_q_J / 2_q_min; os << q; - SECTION("iostream") - { - CHECK(os.str() == "10 [1/6 × 10⁻¹] W"); - } + SECTION("iostream") { CHECK(os.str() == "10 [1/6 × 10⁻¹] W"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num != 1 && unit::ratio::den != 1") @@ -400,20 +257,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 60_q_kJ / 2_q_min; os << q; - SECTION("iostream") - { - CHECK(os.str() == "30 [1/6 × 10²] W"); - } + SECTION("iostream") { CHECK(os.str() == "30 [1/6 × 10²] W"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -424,20 +272,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_m / 2_q_m; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2"); - } + SECTION("iostream") { CHECK(os.str() == "2"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == "2 "); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == "2 "); } } SECTION("one with ratio.exp != 0") @@ -445,20 +284,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_km / 2_q_m; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 × 10³"); - } + SECTION("iostream") { CHECK(os.str() == "2 × 10³"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == "2 × 10³"); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == "2 × 10³"); } } SECTION("percents") @@ -470,20 +300,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") #endif os << q; - SECTION("iostream") - { - CHECK(os.str() == "15 %"); - } + SECTION("iostream") { CHECK(os.str() == "15 %"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -496,20 +317,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2_q_s * 2_q_m * 2_q_kg; os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 m ⋅ kg ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "8 m ⋅ kg ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("CGS base units") @@ -517,20 +329,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2._q_s * si::cgs::length(2) * si::cgs::mass(2); os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 cm ⋅ g ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "8 cm ⋅ g ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } @@ -539,20 +342,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_km * 2_q_s; os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 × 10³ m ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "8 × 10³ m ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num != 1 && unit::ratio::den == 1") @@ -560,20 +354,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_kg * 2_q_min / (2_q_s * 2_q_s); os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 [6 × 10¹] kg/s"); - } + SECTION("iostream") { CHECK(os.str() == "2 [6 × 10¹] kg/s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num == 1 && unit::ratio::den != 1") @@ -581,20 +366,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 20_q_kg / 2_q_min; os << q; - SECTION("iostream") - { - CHECK(os.str() == "10 [1/6 × 10⁻¹] kg/s"); - } + SECTION("iostream") { CHECK(os.str() == "10 [1/6 × 10⁻¹] kg/s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("CGS base units") @@ -602,20 +378,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 2._q_s * si::cgs::length(2) * si::cgs::mass(2); os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 × 10⁵ cm ⋅ g ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "8 × 10⁵ cm ⋅ g ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("unit::ratio::num != 1 && unit::ratio::den != 1") @@ -623,20 +390,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 60_q_min / 2_q_km; os << q; - SECTION("iostream") - { - CHECK(os.str() == "30 [6 × 10⁻²] 1/m ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "30 [6 × 10⁻²] 1/m ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("exponent::num == 1 && exponent::den == 1") @@ -644,20 +402,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_m * 2_q_s; os << q; - SECTION("iostream") - { - CHECK(os.str() == "8 m ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "8 m ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("exponent::num == 2 && exponent::den == 1 for positive exponent") @@ -665,20 +414,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 4_q_m * 2_q_s * 2_q_s; os << q; - SECTION("iostream") - { - CHECK(os.str() == "16 m ⋅ s²"); - } + SECTION("iostream") { CHECK(os.str() == "16 m ⋅ s²"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("exponent::num == 2 && exponent::den == 1 for negative exponent (first dimension)") @@ -686,20 +426,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 8_q_s / 2_q_m / 2_q_m; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 1/m² ⋅ s"); - } + SECTION("iostream") { CHECK(os.str() == "2 1/m² ⋅ s"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("exponent::num == 2 && exponent::den == 1 for negative exponent (not first dimension)") @@ -707,20 +438,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = 8_q_m / 2_q_kg / 2_q_kg; os << q; - SECTION("iostream") - { - CHECK(os.str() == "2 m/kg²"); - } + SECTION("iostream") { CHECK(os.str() == "2 m/kg²"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("fractional positive exponent") @@ -728,20 +450,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = sqrt(9_q_m); os << q; - SECTION("iostream") - { - CHECK(os.str() == "3 m^(1/2)"); - } + SECTION("iostream") { CHECK(os.str() == "3 m^(1/2)"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } SECTION("fractional negative exponent") @@ -749,20 +462,11 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") const auto q = sqrt(9 / 1_q_m); os << q; - SECTION("iostream") - { - CHECK(os.str() == "3 1/m^(1/2)"); - } + SECTION("iostream") { CHECK(os.str() == "3 1/m^(1/2)"); } - SECTION("fmt with default format {} on a quantity") - { - CHECK(STD_FMT::format("{}", q) == os.str()); - } + SECTION("fmt with default format {} on a quantity") { CHECK(STD_FMT::format("{}", q) == os.str()); } - SECTION("fmt with format {:%Q %q} on a quantity") - { - CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); - } + SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(STD_FMT::format("{:%Q %q}", q) == os.str()); } } } } @@ -771,38 +475,23 @@ TEST_CASE("format string with only %Q should print quantity value only", "[text] { SECTION("integral representation") { - SECTION("positive value") - { - CHECK(STD_FMT::format("{:%Q}", 123_q_km_per_h) == "123"); - } + SECTION("positive value") { CHECK(STD_FMT::format("{:%Q}", 123_q_km_per_h) == "123"); } - SECTION("negative value") - { - CHECK(STD_FMT::format("{:%Q}", 5_q_m - 10_q_m) == "-5"); - } + SECTION("negative value") { CHECK(STD_FMT::format("{:%Q}", 5_q_m - 10_q_m) == "-5"); } } SECTION("floating-point representation") { - SECTION("positive value") - { - CHECK(STD_FMT::format("{:%Q}", 221._q_km / 2_q_h) == "110.5"); - } + SECTION("positive value") { CHECK(STD_FMT::format("{:%Q}", 221._q_km / 2_q_h) == "110.5"); } - SECTION("negative value") - { - CHECK(STD_FMT::format("{:%Q}", 3.14_q_m - 10_q_m) == "-6.86"); - } + SECTION("negative value") { CHECK(STD_FMT::format("{:%Q}", 3.14_q_m - 10_q_m) == "-6.86"); } SECTION("nan") { CHECK(STD_FMT::format("{:%Q}", length(std::numeric_limits::quiet_NaN())) == "nan"); } - SECTION("inf") - { - CHECK(STD_FMT::format("{:%Q}", length(std::numeric_limits::infinity())) == "inf"); - } + SECTION("inf") { CHECK(STD_FMT::format("{:%Q}", length(std::numeric_limits::infinity())) == "inf"); } SECTION("-inf") { @@ -825,62 +514,32 @@ TEST_CASE("format string with only %q should print quantity unit symbol only", " SECTION("standard format for a unit with Unicode symbols") { - SECTION("Unicode signs in a unit symbol") - { - CHECK(STD_FMT::format("{:%q}", 123_q_kR) == "kΩ"); - } + SECTION("Unicode signs in a unit symbol") { CHECK(STD_FMT::format("{:%q}", 123_q_kR) == "kΩ"); } - SECTION("Unicode signs in a unit symbol prefix") - { - CHECK(STD_FMT::format("{:%q}", 123_q_uV) == "µV"); - } + SECTION("Unicode signs in a unit symbol prefix") { CHECK(STD_FMT::format("{:%q}", 123_q_uV) == "µV"); } } SECTION("ASCII format for a unit with Unicode symbols") { - SECTION("Unicode signs in a unit symbol") - { - CHECK(STD_FMT::format("{:%Aq}", 123_q_kR) == "kohm"); - } + SECTION("Unicode signs in a unit symbol") { CHECK(STD_FMT::format("{:%Aq}", 123_q_kR) == "kohm"); } - SECTION("Unicode signs in a unit symbol prefix") - { - CHECK(STD_FMT::format("{:%Aq}", 123_q_uV) == "uV"); - } + SECTION("Unicode signs in a unit symbol prefix") { CHECK(STD_FMT::format("{:%Aq}", 123_q_uV) == "uV"); } } } TEST_CASE("%q and %Q can be put anywhere in a format string", "[text][fmt]") { - SECTION("no space") - { - CHECK(STD_FMT::format("{:%Q%q}", 123_q_km_per_h) == "123km/h"); - } + SECTION("no space") { CHECK(STD_FMT::format("{:%Q%q}", 123_q_km_per_h) == "123km/h"); } - SECTION("separator") - { - CHECK(STD_FMT::format("{:%Q###%q}", 123_q_km_per_h) == "123###km/h"); - } + SECTION("separator") { CHECK(STD_FMT::format("{:%Q###%q}", 123_q_km_per_h) == "123###km/h"); } - SECTION("opposite order") - { - CHECK(STD_FMT::format("{:%q %Q}", 123_q_km_per_h) == "km/h 123"); - } + SECTION("opposite order") { CHECK(STD_FMT::format("{:%q %Q}", 123_q_km_per_h) == "km/h 123"); } - SECTION("tabulator") - { - CHECK(STD_FMT::format("{:%Q%t%q}", 123_q_km_per_h) == "123\tkm/h"); - } + SECTION("tabulator") { CHECK(STD_FMT::format("{:%Q%t%q}", 123_q_km_per_h) == "123\tkm/h"); } - SECTION("new line") - { - CHECK(STD_FMT::format("{:%Q%n%q}", 123_q_km_per_h) == "123\nkm/h"); - } + SECTION("new line") { CHECK(STD_FMT::format("{:%Q%n%q}", 123_q_km_per_h) == "123\nkm/h"); } - SECTION("% sign") - { - CHECK(STD_FMT::format("{:%Q%% %q}", 123_q_km_per_h) == "123% km/h"); - } + SECTION("% sign") { CHECK(STD_FMT::format("{:%Q%% %q}", 123_q_km_per_h) == "123% km/h"); } } TEST_CASE("fill and align specification", "[text][fmt][ostream]") @@ -1034,12 +693,14 @@ TEST_CASE("precision specification for integral representation should throw", "[ { SECTION("full format {:%Q %q} on a quantity") { - REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q %q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q %q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, + Message("precision not allowed for integral quantity representation")); } SECTION("value only format {:%Q} on a quantity") { - REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, Message("precision not allowed for integral quantity representation")); + REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, + Message("precision not allowed for integral quantity representation")); } } @@ -1056,32 +717,32 @@ TEST_CASE("type specification", "[text][fmt]") #ifdef UNITS_COMP_MSVC #if UNITS_USE_LIBFMT - CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0 m"); + CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0 m"); CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x1.3c1p+0 m"); - CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0 m"); + CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0 m"); CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X1.3C1P+0 m"); #else - CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0 m"); + CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0 m"); CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "1.3c1p+0 m"); - CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0 m"); + CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0 m"); CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "1.3C1P+0 m"); -#endif // UNITS_USE_LIBFMT +#endif // UNITS_USE_LIBFMT #else - CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3 m"); + CHECK(STD_FMT::format("{:%aQ %q}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3 m"); CHECK(STD_FMT::format("{:%.3aQ %q}", 1.2345678_q_m) == "0x9.e06p-3 m"); - CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3 m"); + CHECK(STD_FMT::format("{:%AQ %q}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3 m"); CHECK(STD_FMT::format("{:%.3AQ %q}", 1.2345678_q_m) == "0X9.E06P-3 m"); #endif - CHECK(STD_FMT::format("{:%eQ %q}", 1.2345678_q_m) == "1.234568e+00 m"); + CHECK(STD_FMT::format("{:%eQ %q}", 1.2345678_q_m) == "1.234568e+00 m"); CHECK(STD_FMT::format("{:%.3eQ %q}", 1.2345678_q_m) == "1.235e+00 m"); - CHECK(STD_FMT::format("{:%EQ %q}", 1.2345678_q_m) == "1.234568E+00 m"); + CHECK(STD_FMT::format("{:%EQ %q}", 1.2345678_q_m) == "1.234568E+00 m"); CHECK(STD_FMT::format("{:%.3EQ %q}", 1.2345678_q_m) == "1.235E+00 m"); - CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678_q_m) == "1.23457 m"); - CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678e8_q_m) == "1.23457e+08 m"); + CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678_q_m) == "1.23457 m"); + CHECK(STD_FMT::format("{:%gQ %q}", 1.2345678e8_q_m) == "1.23457e+08 m"); CHECK(STD_FMT::format("{:%.3gQ %q}", 1.2345678_q_m) == "1.23 m"); CHECK(STD_FMT::format("{:%.3gQ %q}", 1.2345678e8_q_m) == "1.23e+08 m"); - CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678_q_m) == "1.23457 m"); - CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678e8_q_m) == "1.23457E+08 m"); + CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678_q_m) == "1.23457 m"); + CHECK(STD_FMT::format("{:%GQ %q}", 1.2345678e8_q_m) == "1.23457E+08 m"); CHECK(STD_FMT::format("{:%.3GQ %q}", 1.2345678_q_m) == "1.23 m"); CHECK(STD_FMT::format("{:%.3GQ %q}", 1.2345678e8_q_m) == "1.23E+08 m"); } @@ -1097,32 +758,32 @@ TEST_CASE("type specification", "[text][fmt]") #ifdef UNITS_COMP_MSVC #if UNITS_USE_LIBFMT - CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0"); + CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x1.3c0ca2a5b1d5dp+0"); CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x1.3c1p+0"); - CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0"); + CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X1.3C0CA2A5B1D5DP+0"); CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X1.3C1P+0"); #else - CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0"); + CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "1.3c0ca2a5b1d5dp+0"); CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "1.3c1p+0"); - CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0"); + CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "1.3C0CA2A5B1D5DP+0"); CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "1.3C1P+0"); -#endif // UNITS_USE_LIBFMT +#endif // UNITS_USE_LIBFMT #else - CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3"); + CHECK(STD_FMT::format("{:%aQ}", 1.2345678_q_m) == "0x9.e065152d8eae841p-3"); CHECK(STD_FMT::format("{:%.3aQ}", 1.2345678_q_m) == "0x9.e06p-3"); - CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3"); + CHECK(STD_FMT::format("{:%AQ}", 1.2345678_q_m) == "0X9.E065152D8EAE841P-3"); CHECK(STD_FMT::format("{:%.3AQ}", 1.2345678_q_m) == "0X9.E06P-3"); #endif - CHECK(STD_FMT::format("{:%eQ}", 1.2345678_q_m) == "1.234568e+00"); + CHECK(STD_FMT::format("{:%eQ}", 1.2345678_q_m) == "1.234568e+00"); CHECK(STD_FMT::format("{:%.3eQ}", 1.2345678_q_m) == "1.235e+00"); - CHECK(STD_FMT::format("{:%EQ}", 1.2345678_q_m) == "1.234568E+00"); + CHECK(STD_FMT::format("{:%EQ}", 1.2345678_q_m) == "1.234568E+00"); CHECK(STD_FMT::format("{:%.3EQ}", 1.2345678_q_m) == "1.235E+00"); - CHECK(STD_FMT::format("{:%gQ}", 1.2345678_q_m) == "1.23457"); - CHECK(STD_FMT::format("{:%gQ}", 1.2345678e8_q_m) == "1.23457e+08"); + CHECK(STD_FMT::format("{:%gQ}", 1.2345678_q_m) == "1.23457"); + CHECK(STD_FMT::format("{:%gQ}", 1.2345678e8_q_m) == "1.23457e+08"); CHECK(STD_FMT::format("{:%.3gQ}", 1.2345678_q_m) == "1.23"); CHECK(STD_FMT::format("{:%.3gQ}", 1.2345678e8_q_m) == "1.23e+08"); - CHECK(STD_FMT::format("{:%GQ}", 1.2345678_q_m) == "1.23457"); - CHECK(STD_FMT::format("{:%GQ}", 1.2345678e8_q_m) == "1.23457E+08"); + CHECK(STD_FMT::format("{:%GQ}", 1.2345678_q_m) == "1.23457"); + CHECK(STD_FMT::format("{:%GQ}", 1.2345678e8_q_m) == "1.23457E+08"); CHECK(STD_FMT::format("{:%.3GQ}", 1.2345678_q_m) == "1.23"); CHECK(STD_FMT::format("{:%.3GQ}", 1.2345678e8_q_m) == "1.23E+08"); } @@ -1151,16 +812,14 @@ TEST_CASE("different base types with the # specifier", "[text][fmt]") TEST_CASE("localization with the 'L' specifier", "[text][fmt][localization]") { - struct group2 : std::numpunct - { - char do_thousands_sep() const override { return '_'; } - std::string do_grouping() const override { return "\2"; } + struct group2 : std::numpunct { + char do_thousands_sep() const override { return '_'; } + std::string do_grouping() const override { return "\2"; } }; - struct group3 : std::numpunct - { - char do_thousands_sep() const override { return '\''; } - std::string do_grouping() const override { return "\3"; } + struct group3 : std::numpunct { + char do_thousands_sep() const override { return '\''; } + std::string do_grouping() const override { return "\3"; } }; std::locale grp2{std::locale::classic(), new group2}; diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 05070590..c94c3734 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -20,7 +20,8 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include // IWYU pragma: keep +#include +#include // IWYU pragma: keep #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include using namespace units::isq::si; using namespace units::isq::si::references; @@ -80,10 +80,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{}", 1_q_point_prn) == "1 point(prn)"); } - SECTION("mass") - { - CHECK(STD_FMT::format("{}", 1_q_kg) == "1 kg"); - } + SECTION("mass") { CHECK(STD_FMT::format("{}", 1_q_kg) == "1 kg"); } SECTION("area") { @@ -189,15 +186,9 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{}", 1_q_GW) == "1 GW"); } - SECTION("surface tension") - { - CHECK(STD_FMT::format("{}", 1_q_N_per_m) == "1 N/m"); - } + SECTION("surface tension") { CHECK(STD_FMT::format("{}", 1_q_N_per_m) == "1 N/m"); } - SECTION("magnetic induction") - { - CHECK(STD_FMT::format("{}", 1_q_T) == "1 T"); - } + SECTION("magnetic induction") { CHECK(STD_FMT::format("{}", 1_q_T) == "1 T"); } SECTION("magnetic flux") { @@ -230,10 +221,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{}", 1_q_mGy) == "1 mGy"); } - SECTION("addition with common ratio") - { - CHECK(STD_FMT::format("{}", 1_q_in + 1_q_yd) == "37 in"); - } + SECTION("addition with common ratio") { CHECK(STD_FMT::format("{}", 1_q_in + 1_q_yd) == "37 in"); } SECTION("current density") { @@ -259,10 +247,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_Pa_s) == "1 Pa s"); } - SECTION("heat capacity") - { - CHECK(STD_FMT::format("{}", 1_q_J_per_K) == "1 J/K"); - } + SECTION("heat capacity") { CHECK(STD_FMT::format("{}", 1_q_J_per_K) == "1 J/K"); } SECTION("specific heat capacity") { @@ -282,10 +267,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_W_per_m_K) == "1 W m^-1 K^-1"); } - SECTION("electric field strength") - { - CHECK(STD_FMT::format("{}", 1_q_V_per_m) == "1 V/m"); - } + SECTION("electric field strength") { CHECK(STD_FMT::format("{}", 1_q_V_per_m) == "1 V/m"); } SECTION("charge density") { @@ -295,25 +277,13 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{:%Q %Aq}", 1_q_C_per_m2) == "1 C/m^2"); } - SECTION("permittivity") - { - CHECK(STD_FMT::format("{}", 1_q_F_per_m) == "1 F/m"); - } + SECTION("permittivity") { CHECK(STD_FMT::format("{}", 1_q_F_per_m) == "1 F/m"); } - SECTION("permeability") - { - CHECK(STD_FMT::format("{}", 1_q_H_per_m) == "1 H/m"); - } + SECTION("permeability") { CHECK(STD_FMT::format("{}", 1_q_H_per_m) == "1 H/m"); } - SECTION("molar energy") - { - CHECK(STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); - } + SECTION("molar energy") { CHECK(STD_FMT::format("{}", 1_q_J_per_mol) == "1 J/mol"); } - SECTION("torque") - { - CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N ⋅ m/rad"); - } + SECTION("torque") { CHECK(STD_FMT::format("{}", 1_q_N_m_per_rad) == "1 N ⋅ m/rad"); } SECTION("storage_capacity") { @@ -332,10 +302,7 @@ TEST_CASE("std::format on synthesized unit symbols", "[text][fmt]") CHECK(STD_FMT::format("{}", 1 * (TB / s)) == "1 TB/s"); } - SECTION("traffic_intesity") - { - CHECK(STD_FMT::format("{}", 1 * E) == "1 E"); - } + SECTION("traffic_intesity") { CHECK(STD_FMT::format("{}", 1 * E) == "1 E"); } SECTION("modulation_rate") { diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index 3def404b..be32bb73 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -20,25 +20,39 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include #include #include -#include #include namespace units { // A set of non-standard bases for testing purposes. -struct noninteger_base { static constexpr long double value = 1.234L; }; -struct noncanonical_two_base { static constexpr long double value = 2.0L; }; -struct other_noncanonical_two_base { static constexpr long double value = 2.0L; }; -struct invalid_zero_base { static constexpr long double value = 0.0L; }; -struct invalid_negative_base { static constexpr long double value = -1.234L; }; +struct noninteger_base { + static constexpr long double value = 1.234L; +}; +struct noncanonical_two_base { + static constexpr long double value = 2.0L; +}; +struct other_noncanonical_two_base { + static constexpr long double value = 2.0L; +}; +struct invalid_zero_base { + static constexpr long double value = 0.0L; +}; +struct invalid_negative_base { + static constexpr long double value = -1.234L; +}; template -constexpr auto pi_to_the() { return magnitude{Power}>{}; } +constexpr auto pi_to_the() +{ + return magnitude{Power}>{}; +} template -void check_same_type_and_value(T actual, U expected) { +void check_same_type_and_value(T actual, U expected) +{ CHECK(std::is_same_v); CHECK(actual == expected); } @@ -93,9 +107,7 @@ TEST_CASE("base_power") SECTION("product with inverse equals identity") { - auto check_product_with_inverse_is_identity = [] (auto x) { - CHECK(x * pow<-1>(x) == as_magnitude<1>()); - }; + auto check_product_with_inverse_is_identity = [](auto x) { CHECK(x * pow<-1>(x) == as_magnitude<1>()); }; check_product_with_inverse_is_identity(as_magnitude<3>()); check_product_with_inverse_is_identity(as_magnitude()); @@ -122,10 +134,7 @@ TEST_CASE("make_ratio performs prime factorization correctly") CHECK(as_magnitude<792>() == magnitude{}); } - SECTION("Supports fractions") - { - CHECK(as_magnitude() == magnitude{}); - } + SECTION("Supports fractions") { CHECK(as_magnitude() == magnitude{}); } SECTION("Supports nonzero exp") { @@ -196,7 +205,7 @@ TEST_CASE("magnitude converts to numerical value") // Would work for pow<63>: // get_value(pow<64>(as_magnitude<2>())); - get_value(pow<308>(as_magnitude<10>())); // Compiles, correctly. + get_value(pow<308>(as_magnitude<10>())); // Compiles, correctly. // get_value(pow<309>(as_magnitude<10>())); // get_value(pow<3099>(as_magnitude<10>())); // get_value(pow<3099999>(as_magnitude<10>())); @@ -243,9 +252,8 @@ TEST_CASE("Multiplication works for magnitudes") SECTION("Products handle pi correctly") { - CHECK( - pi_to_the<1>() * as_magnitude() * pi_to_the() == - magnitude{ratio{1, 2}}>{}); + CHECK(pi_to_the<1>() * as_magnitude() * pi_to_the() == + magnitude{ratio{1, 2}}>{}); } SECTION("Supports constexpr") @@ -277,21 +285,24 @@ TEST_CASE("Division works for magnitudes") TEST_CASE("Can raise Magnitudes to rational powers") { - SECTION("Anything to the 0 is 1") { + SECTION("Anything to the 0 is 1") + { CHECK(pow<0>(as_magnitude<1>()) == as_magnitude<1>()); CHECK(pow<0>(as_magnitude<123>()) == as_magnitude<1>()); CHECK(pow<0>(as_magnitude()) == as_magnitude<1>()); CHECK(pow<0>(pi_to_the()) == as_magnitude<1>()); } - SECTION("Anything to the 1 is itself") { + SECTION("Anything to the 1 is itself") + { CHECK(pow<1>(as_magnitude<1>()) == as_magnitude<1>()); CHECK(pow<1>(as_magnitude<123>()) == as_magnitude<123>()); CHECK(pow<1>(as_magnitude()) == as_magnitude()); CHECK(pow<1>(pi_to_the()) == pi_to_the()); } - SECTION("Can raise to arbitrary rational power") { + SECTION("Can raise to arbitrary rational power") + { CHECK(pow(pi_to_the()) == pi_to_the()); } } @@ -325,8 +336,10 @@ TEST_CASE("can distinguish integral, rational, and irrational magnitudes") namespace detail { -TEST_CASE("int_power computes integer powers") { - SECTION("handles floating point") { +TEST_CASE("int_power computes integer powers") +{ + SECTION("handles floating point") + { check_same_type_and_value(int_power(0.123L, 0), 1.0L); check_same_type_and_value(int_power(0.246f, 1), 0.246f); check_same_type_and_value(int_power(0.5f, 3), 0.125f); @@ -335,7 +348,8 @@ TEST_CASE("int_power computes integer powers") { CHECK(std::is_same_v(base_power{10, 20}))>); } - SECTION("handles integral") { + SECTION("handles integral") + { check_same_type_and_value(int_power(8, 0), 1); check_same_type_and_value(int_power(9L, 1), 9L); check_same_type_and_value(int_power(2, 10), 1024); @@ -344,7 +358,8 @@ TEST_CASE("int_power computes integer powers") { TEST_CASE("Prime helper functions") { - SECTION("find_first_factor()") { + SECTION("find_first_factor()") + { CHECK(find_first_factor(1) == 1); CHECK(find_first_factor(2) == 2); CHECK(find_first_factor(4) == 2); @@ -353,13 +368,15 @@ TEST_CASE("Prime helper functions") CHECK(find_first_factor(17) == 17); } - SECTION("multiplicity") { + SECTION("multiplicity") + { CHECK(multiplicity(2, 8) == 3); CHECK(multiplicity(2, 1024) == 10); CHECK(multiplicity(11, 6655) == 3); } - SECTION("remove_power()") { + SECTION("remove_power()") + { CHECK(remove_power(17, 0, 5) == 5); CHECK(remove_power(2, 3, 24) == 3); CHECK(remove_power(11, 3, 6655) == 5); @@ -368,10 +385,7 @@ TEST_CASE("Prime helper functions") TEST_CASE("Prime factorization") { - SECTION("1 factors into the null magnitude") - { - CHECK(prime_factorization_v<1> == magnitude<>{}); - } + SECTION("1 factors into the null magnitude") { CHECK(prime_factorization_v<1> == magnitude<>{}); } SECTION("Prime numbers factor into themselves") { @@ -386,8 +400,7 @@ TEST_CASE("Prime factorization") SECTION("Prime factorization finds factors and multiplicities") { - CHECK(prime_factorization_v<792> == - magnitude{}); + CHECK(prime_factorization_v<792> == magnitude{}); } } @@ -400,10 +413,7 @@ TEST_CASE("is_prime detects primes") CHECK(!is_prime(0)); } - SECTION("1 is not prime") - { - CHECK(!is_prime(1)); - } + SECTION("1 is not prime") { CHECK(!is_prime(1)); } SECTION("Discriminates between primes and non-primes") { @@ -422,7 +432,8 @@ TEST_CASE("is_prime detects primes") TEST_CASE("is_valid_base_power") { - SECTION("0 power is invalid") { + SECTION("0 power is invalid") + { REQUIRE(is_valid_base_power(base_power{2})); CHECK(!is_valid_base_power(base_power{2, 0})); @@ -433,7 +444,8 @@ TEST_CASE("is_valid_base_power") CHECK(!is_valid_base_power(base_power{0})); } - SECTION("non-prime integers are invalid") { + SECTION("non-prime integers are invalid") + { CHECK(!is_valid_base_power(base_power{-8})); CHECK(!is_valid_base_power(base_power{0})); CHECK(!is_valid_base_power(base_power{1})); @@ -444,7 +456,8 @@ TEST_CASE("is_valid_base_power") CHECK(!is_valid_base_power(base_power{4})); } - SECTION("non-positive floating point bases are invalid") { + SECTION("non-positive floating point bases are invalid") + { CHECK(!is_valid_base_power(base_power{})); CHECK(!is_valid_base_power(base_power{})); } @@ -452,8 +465,8 @@ TEST_CASE("is_valid_base_power") TEST_CASE("pairwise_all evaluates all pairs") { - const auto all_pairs_return_true = pairwise_all{[](auto, auto){ return true; }}; - const auto all_pairs_return_false = pairwise_all{[](auto, auto){ return false; }}; + const auto all_pairs_return_true = pairwise_all{[](auto, auto) { return true; }}; + const auto all_pairs_return_false = pairwise_all{[](auto, auto) { return false; }}; const auto all_increasing = pairwise_all{std::less{}}; SECTION("always true for empty tuples") @@ -484,10 +497,7 @@ TEST_CASE("pairwise_all evaluates all pairs") TEST_CASE("strictly_increasing") { - SECTION("Empty input is sorted") - { - CHECK(strictly_increasing()); - } + SECTION("Empty input is sorted") { CHECK(strictly_increasing()); } SECTION("Single-element input is sorted") { @@ -504,6 +514,6 @@ TEST_CASE("strictly_increasing") } } -} // namespace detail +} // namespace detail -} // namespace units +} // namespace units diff --git a/test/unit_test/runtime/math_test.cpp b/test/unit_test/runtime/math_test.cpp index ee56fefc..d74c93ef 100644 --- a/test/unit_test/runtime/math_test.cpp +++ b/test/unit_test/runtime/math_test.cpp @@ -20,12 +20,12 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include #include -#include #include -#include +#include +#include #include using namespace units; @@ -36,21 +36,13 @@ using namespace units::isq::si; TEST_CASE("'pow()' on quantity changes the value and the dimension accordingly", "[math][pow]") { - SECTION ("'pow<0>(q)' returns '1'") { - CHECK(pow<0>(2_q_m) == 1); - } + SECTION("'pow<0>(q)' returns '1'") { CHECK(pow<0>(2_q_m) == 1); } - SECTION ("'pow<1>(q)' returns 'q'") { - CHECK(pow<1>(2_q_m) == 2_q_m); - } + SECTION("'pow<1>(q)' returns 'q'") { CHECK(pow<1>(2_q_m) == 2_q_m); } - SECTION ("'pow<2>(q)' squares both the value and a dimension") { - CHECK(pow<2>(2_q_m) == 4_q_m2); - } + SECTION("'pow<2>(q)' squares both the value and a dimension") { CHECK(pow<2>(2_q_m) == 4_q_m2); } - SECTION ("'pow<3>(q)' cubes both the value and a dimension") { - CHECK(pow<3>(2_q_m) == 8_q_m3); - } + SECTION("'pow<3>(q)' cubes both the value and a dimension") { CHECK(pow<3>(2_q_m) == 8_q_m3); } } TEST_CASE("'sqrt()' on quantity changes the value and the dimension accordingly", "[math][sqrt]") @@ -70,85 +62,86 @@ TEST_CASE("'pow()' on quantity changes the value and the dimension acc TEST_CASE("absolute functions on quantity returns the absolute value", "[math][abs][fabs]") { - SECTION ("'abs()' on a negative quantity returns the abs") + SECTION("'abs()' on a negative quantity returns the abs") { - SECTION ("integral representation") - { - REQUIRE(abs(-1_q_m) == 1_q_m); - } + SECTION("integral representation") { REQUIRE(abs(-1_q_m) == 1_q_m); } - SECTION ("floating-point representation") - { - REQUIRE(abs(-1._q_m) == 1_q_m); - } + SECTION("floating-point representation") { REQUIRE(abs(-1._q_m) == 1_q_m); } } - SECTION ("'abs()' on a positive quantity returns the abs") + SECTION("'abs()' on a positive quantity returns the abs") { - SECTION ("integral representation") - { - REQUIRE(abs(1_q_m) == 1_q_m); - } + SECTION("integral representation") { REQUIRE(abs(1_q_m) == 1_q_m); } - SECTION ("floating-point representation") - { - REQUIRE(abs(1._q_m) == 1_q_m); - } + SECTION("floating-point representation") { REQUIRE(abs(1._q_m) == 1_q_m); } } } TEST_CASE("numeric_limits functions", "[limits]") { - SECTION ("'epsilon' works as expected using default floating type") { + SECTION("'epsilon' works as expected using default floating type") + { REQUIRE(epsilon().number() == std::numeric_limits::epsilon()); } - SECTION ("'epsilon' works as expected using integers") { + SECTION("'epsilon' works as expected using integers") + { REQUIRE(epsilon().number() == std::numeric_limits::epsilon()); } - SECTION ("'epsilon' works as expected using mixed Rep types") { + SECTION("'epsilon' works as expected using mixed Rep types") + { REQUIRE(epsilon().number() != std::numeric_limits::epsilon()); } } TEST_CASE("floor functions", "[floor]") { - SECTION ("floor 1 second with target unit second should be 1 second") { - REQUIRE(floor(1_q_s) == 1_q_s); - } - SECTION ("floor 1000 milliseconds with target unit second should be 1 second") { + SECTION("floor 1 second with target unit second should be 1 second") { REQUIRE(floor(1_q_s) == 1_q_s); } + SECTION("floor 1000 milliseconds with target unit second should be 1 second") + { REQUIRE(floor(1000_q_ms) == 1_q_s); } - SECTION ("floor 1001 milliseconds with target unit second should be 1 second") { + SECTION("floor 1001 milliseconds with target unit second should be 1 second") + { REQUIRE(floor(1001_q_ms) == 1_q_s); } - SECTION ("floor 1999 milliseconds with target unit second should be 1 second") { + SECTION("floor 1999 milliseconds with target unit second should be 1 second") + { REQUIRE(floor(1999_q_ms) == 1_q_s); } - SECTION ("floor -1000 milliseconds with target unit second should be -1 second") { + SECTION("floor -1000 milliseconds with target unit second should be -1 second") + { REQUIRE(floor(-1000_q_ms) == -1_q_s); } - SECTION ("floor -999 milliseconds with target unit second should be -1 second") { + SECTION("floor -999 milliseconds with target unit second should be -1 second") + { REQUIRE(floor(-999_q_ms) == -1_q_s); } - SECTION ("floor 1.3 seconds with target unit second should be 1 second") { + SECTION("floor 1.3 seconds with target unit second should be 1 second") + { REQUIRE(floor(1.3_q_s) == 1_q_s); } - SECTION ("floor -1.3 seconds with target unit second should be -2 seconds") { + SECTION("floor -1.3 seconds with target unit second should be -2 seconds") + { REQUIRE(floor(-1.3_q_s) == -2_q_s); } - SECTION ("floor 1001. milliseconds with target unit second should be 1 second") { + SECTION("floor 1001. milliseconds with target unit second should be 1 second") + { REQUIRE(floor(1001._q_ms) == 1_q_s); } - SECTION ("floor 1999. milliseconds with target unit second should be 1 second") { + SECTION("floor 1999. milliseconds with target unit second should be 1 second") + { REQUIRE(floor(1999._q_ms) == 1_q_s); } - SECTION ("floor -1000. milliseconds with target unit second should be -1 second") { + SECTION("floor -1000. milliseconds with target unit second should be -1 second") + { REQUIRE(floor(-1000._q_ms) == -1_q_s); } - SECTION ("floor -999. milliseconds with target unit second should be -1 second") { + SECTION("floor -999. milliseconds with target unit second should be -1 second") + { REQUIRE(floor(-999._q_ms) == -1_q_s); } - SECTION ("floor 1 second with target quantity with unit type second should be 1 second") { + SECTION("floor 1 second with target quantity with unit type second should be 1 second") + { using showtime = si::time; REQUIRE(floor(showtime::one()) == showtime::one()); } @@ -156,44 +149,53 @@ TEST_CASE("floor functions", "[floor]") TEST_CASE("ceil functions", "[ceil]") { - SECTION ("ceil 1 second with target unit second should be 1 second") { - REQUIRE(ceil(1_q_s) == 1_q_s); - } - SECTION ("ceil 1000 milliseconds with target unit second should be 1 second") { + SECTION("ceil 1 second with target unit second should be 1 second") { REQUIRE(ceil(1_q_s) == 1_q_s); } + SECTION("ceil 1000 milliseconds with target unit second should be 1 second") + { REQUIRE(ceil(1000_q_ms) == 1_q_s); } - SECTION ("ceil 1001 milliseconds with target unit second should be 2 seconds") { + SECTION("ceil 1001 milliseconds with target unit second should be 2 seconds") + { REQUIRE(ceil(1001_q_ms) == 2_q_s); } - SECTION ("ceil 1999 milliseconds with target unit second should be 2 seconds") { + SECTION("ceil 1999 milliseconds with target unit second should be 2 seconds") + { REQUIRE(ceil(1999_q_ms) == 2_q_s); } - SECTION ("ceil -1000 milliseconds with target unit second should be -1 second") { + SECTION("ceil -1000 milliseconds with target unit second should be -1 second") + { REQUIRE(ceil(-1000_q_ms) == -1_q_s); } - SECTION ("ceil -999 milliseconds with target unit second should be 0 seconds") { + SECTION("ceil -999 milliseconds with target unit second should be 0 seconds") + { REQUIRE(ceil(-999_q_ms) == 0_q_s); } - SECTION ("ceil 1.3 seconds with target unit second should be 2 seconds") { + SECTION("ceil 1.3 seconds with target unit second should be 2 seconds") + { REQUIRE(ceil(1.3_q_s) == 2_q_s); } - SECTION ("ceil -1.3 seconds with target unit second should be -1 second") { + SECTION("ceil -1.3 seconds with target unit second should be -1 second") + { REQUIRE(ceil(-1.3_q_s) == -1_q_s); } - SECTION ("ceil 1001. milliseconds with target unit second should be 2 seconds") { + SECTION("ceil 1001. milliseconds with target unit second should be 2 seconds") + { REQUIRE(ceil(1001._q_ms) == 2_q_s); } - SECTION ("ceil 1999. milliseconds with target unit second should be 2 seconds") { + SECTION("ceil 1999. milliseconds with target unit second should be 2 seconds") + { REQUIRE(ceil(1999._q_ms) == 2_q_s); } -// TODO does not work, probably due to a bug in fpow10() see #311 -// SECTION ("ceil -1000. milliseconds with target unit second should be -1 second") { -// REQUIRE(ceil(-1000._q_ms) == -1_q_s); -// } - SECTION ("ceil -999. milliseconds with target unit second should be 0 seconds") { + // TODO does not work, probably due to a bug in fpow10() see #311 + // SECTION ("ceil -1000. milliseconds with target unit second should be -1 second") { + // REQUIRE(ceil(-1000._q_ms) == -1_q_s); + // } + SECTION("ceil -999. milliseconds with target unit second should be 0 seconds") + { REQUIRE(ceil(-999._q_ms) == 0_q_s); } - SECTION ("ceil 1 second with target quantity with unit type second should be 1 second") { + SECTION("ceil 1 second with target quantity with unit type second should be 1 second") + { using showtime = si::time; REQUIRE(ceil(showtime::one()) == showtime::one()); } @@ -201,70 +203,89 @@ TEST_CASE("ceil functions", "[ceil]") TEST_CASE("round functions", "[round]") { - SECTION ("round 1 second with target unit second should be 1 second") { - REQUIRE(round(1_q_s) == 1_q_s); - } - SECTION ("round 1000 milliseconds with target unit second should be 1 second") { + SECTION("round 1 second with target unit second should be 1 second") { REQUIRE(round(1_q_s) == 1_q_s); } + SECTION("round 1000 milliseconds with target unit second should be 1 second") + { REQUIRE(round(1000_q_ms) == 1_q_s); } - SECTION ("round 1001 milliseconds with target unit second should be 1 second") { + SECTION("round 1001 milliseconds with target unit second should be 1 second") + { REQUIRE(round(1001_q_ms) == 1_q_s); } - SECTION ("round 1499 milliseconds with target unit second should be 1 second") { + SECTION("round 1499 milliseconds with target unit second should be 1 second") + { REQUIRE(round(1499_q_ms) == 1_q_s); } - SECTION ("round 1500 milliseconds with target unit second should be 2 seconds") { + SECTION("round 1500 milliseconds with target unit second should be 2 seconds") + { REQUIRE(round(1500_q_ms) == 2_q_s); } - SECTION ("round 1999 milliseconds with target unit second should be 2 seconds") { + SECTION("round 1999 milliseconds with target unit second should be 2 seconds") + { REQUIRE(round(1999_q_ms) == 2_q_s); } - SECTION ("round -1000 milliseconds with target unit second should be -1 second") { + SECTION("round -1000 milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1000_q_ms) == -1_q_s); } - SECTION ("round -1001 milliseconds with target unit second should be -1 second") { + SECTION("round -1001 milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1001_q_ms) == -1_q_s); } - SECTION ("round -1499 milliseconds with target unit second should be -1 second") { + SECTION("round -1499 milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1499_q_ms) == -1_q_s); } - SECTION ("round -1500 milliseconds with target unit second should be -2 seconds") { + SECTION("round -1500 milliseconds with target unit second should be -2 seconds") + { REQUIRE(round(-1500_q_ms) == -2_q_s); } - SECTION ("round -1999 milliseconds with target unit second should be -2 seconds") { + SECTION("round -1999 milliseconds with target unit second should be -2 seconds") + { REQUIRE(round(-1999_q_ms) == -2_q_s); } - SECTION ("round 1000. milliseconds with target unit second should be 1 second") { + SECTION("round 1000. milliseconds with target unit second should be 1 second") + { REQUIRE(round(1000._q_ms) == 1_q_s); } - SECTION ("round 1001. milliseconds with target unit second should be 1 second") { + SECTION("round 1001. milliseconds with target unit second should be 1 second") + { REQUIRE(round(1001._q_ms) == 1_q_s); } - SECTION ("round 1499. milliseconds with target unit second should be 1 second") { + SECTION("round 1499. milliseconds with target unit second should be 1 second") + { REQUIRE(round(1499._q_ms) == 1_q_s); } - SECTION ("round 1500. milliseconds with target unit second should be 2 seconds") { + SECTION("round 1500. milliseconds with target unit second should be 2 seconds") + { REQUIRE(round(1500._q_ms) == 2_q_s); } - SECTION ("round 1999. milliseconds with target unit second should be 2 seconds") { + SECTION("round 1999. milliseconds with target unit second should be 2 seconds") + { REQUIRE(round(1999._q_ms) == 2_q_s); } - SECTION ("round -1000. milliseconds with target unit second should be -1 second") { + SECTION("round -1000. milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1000._q_ms) == -1_q_s); } - SECTION ("round -1001. milliseconds with target unit second should be -1 second") { + SECTION("round -1001. milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1001._q_ms) == -1_q_s); } - SECTION ("round -1499. milliseconds with target unit second should be -1 second") { + SECTION("round -1499. milliseconds with target unit second should be -1 second") + { REQUIRE(round(-1499._q_ms) == -1_q_s); } - SECTION ("round -1500. milliseconds with target unit second should be -2 seconds") { + SECTION("round -1500. milliseconds with target unit second should be -2 seconds") + { REQUIRE(round(-1500._q_ms) == -2_q_s); } - SECTION ("round -1999. milliseconds with target unit second should be -2 seconds") { + SECTION("round -1999. milliseconds with target unit second should be -2 seconds") + { REQUIRE(round(-1999._q_ms) == -2_q_s); } - SECTION ("round 1 second with target quantity with unit type second should be 1 second") { + SECTION("round 1 second with target quantity with unit type second should be 1 second") + { using showtime = si::time; REQUIRE(round(showtime::one()) == showtime::one()); } @@ -281,7 +302,7 @@ template struct Pow { constexpr static std::intmax_t exponent = N; template - [[nodiscard]] constexpr static auto pow(T const& v) noexcept + [[nodiscard]] constexpr static auto pow(const T& v) noexcept { return detail::pow_impl(v); } @@ -301,8 +322,9 @@ struct RuntimeRoot : Pow { template static void root_test() { - SECTION ("Roots are truncated down") { - auto base = GENERATE(range(1.0, 10.0, 1.0)); // doubles to guard against overflow + SECTION("Roots are truncated down") + { + auto base = GENERATE(range(1.0, 10.0, 1.0)); // doubles to guard against overflow if (TestType::pow(base) < static_cast(std::numeric_limits::max())) { const std::intmax_t x = TestType::pow(static_cast(base)); @@ -313,7 +335,8 @@ static void root_test() } } - SECTION ("Roots are truncated correctly for very large inputs") { + SECTION("Roots are truncated correctly for very large inputs") + { auto exponent = GENERATE(range(10, std::numeric_limits::digits10, 1)); const auto large_val = static_cast(std::pow(10, exponent)); const auto expected = static_cast(std::pow(10, exponent / static_cast(TestType::exponent))); diff --git a/test/unit_test/static/cgs_test.cpp b/test/unit_test/static/cgs_test.cpp index 99549ad9..35dfd87b 100644 --- a/test/unit_test/static/cgs_test.cpp +++ b/test/unit_test/static/cgs_test.cpp @@ -100,4 +100,4 @@ static_assert(10_q_erg / 1_q_erg_per_s == 10_q_s); static_assert(detail::unit_text() == "erg/s"); -} +} // namespace diff --git a/test/unit_test/static/chrono_test.cpp b/test/unit_test/static/chrono_test.cpp index 547bebe6..348ec3ba 100644 --- a/test/unit_test/static/chrono_test.cpp +++ b/test/unit_test/static/chrono_test.cpp @@ -34,9 +34,11 @@ using namespace units::isq; using namespace units::isq::si::literals; using namespace std::chrono_literals; using sys_seconds = std::chrono::time_point; -using sys_days = std::chrono::time_point, std::chrono::hours::period>>>; -template using time_point = quantity_point, U, Rep>; +using sys_days = + std::chrono::time_point, std::chrono::hours::period>>>; +template +using time_point = quantity_point, U, Rep>; static_assert(QuantityLike); static_assert(QuantityPointLike); @@ -50,8 +52,10 @@ static_assert(std::constructible_from>); static_assert(!std::constructible_from, std::chrono::seconds>); static_assert(!std::convertible_to>); -static_assert(std::constructible_from, sys_seconds>); -static_assert(!std::constructible_from, sys_seconds>); +static_assert( + std::constructible_from, sys_seconds>); +static_assert( + !std::constructible_from, sys_seconds>); static_assert(!std::convertible_to>); static_assert(std::constructible_from, sys_days>); static_assert(!std::constructible_from, sys_days>); @@ -80,8 +84,10 @@ static_assert(!std::convertible_to>); static_assert(is_same_v>); -static_assert(is_same_v>); -static_assert(is_same_v>); +static_assert(is_same_v>); +static_assert(is_same_v>); // operators static_assert(quantity{1s} + 1_q_s == 2_q_s); diff --git a/test/unit_test/static/concepts_test.cpp b/test/unit_test/static/concepts_test.cpp index a54e3cd5..d1c1e2bf 100644 --- a/test/unit_test/static/concepts_test.cpp +++ b/test/unit_test/static/concepts_test.cpp @@ -20,15 +20,15 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include -#include // IWYU pragma: keep -#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include -#include #include #include #include @@ -141,9 +141,13 @@ static_assert(QuantityOf, si::dim_length>); static_assert(QuantityOf, si::fps::dim_length>); static_assert(!QuantityOf, si::dim_time>); -static_assert(QuantityPointOf, si::second, int>, dynamic_origin>); -static_assert(QuantityPointOf, si::second, int>, clock_origin>); -static_assert(!QuantityPointOf, si::second, int>, clock_origin>); -static_assert(!QuantityPointOf, si::second, int>, dynamic_origin>); +static_assert( + QuantityPointOf, si::second, int>, dynamic_origin>); +static_assert(QuantityPointOf, si::second, int>, + clock_origin>); +static_assert(!QuantityPointOf, si::second, int>, + clock_origin>); +static_assert(!QuantityPointOf, si::second, int>, + dynamic_origin>); } // namespace diff --git a/test/unit_test/static/custom_rep_test_min_expl.cpp b/test/unit_test/static/custom_rep_test_min_expl.cpp index 9ab08c97..37a511f2 100644 --- a/test/unit_test/static/custom_rep_test_min_expl.cpp +++ b/test/unit_test/static/custom_rep_test_min_expl.cpp @@ -30,13 +30,13 @@ namespace { /** * @brief Representation type meeting minimum requirements - * + * * This type with a default Mode = 0 provides the minimum set of requirements to * satisfy @c Representation concept which is used for quantity's representation type. - * + * * In case of Mode != 0 only one of mandatory operation is removed which should * result in @c Representation concept not being satisfied. - * + * * @tparam Mode a flag to disable specific type's operations */ template @@ -44,38 +44,64 @@ class min_expl { std::intmax_t value_; public: // default construction - min_expl() requires (Mode != 1) = default; + min_expl() + requires(Mode != 1) + = default; // construction from std::int64_t - constexpr explicit min_expl(std::intmax_t v) noexcept requires (Mode != 2) : value_(v) {} + constexpr explicit min_expl(std::intmax_t v) noexcept + requires(Mode != 2) + : value_(v) + { + } // copy construction - min_expl(const min_expl&) requires (Mode != 3) = default; + min_expl(const min_expl&) + requires(Mode != 3) + = default; // move construction - min_expl(min_expl&&) requires (Mode != 4) = default; - min_expl(min_expl&&) requires (Mode == 4) = delete; + min_expl(min_expl&&) + requires(Mode != 4) + = default; + min_expl(min_expl&&) + requires(Mode == 4) + = delete; // copy assignment - min_expl& operator=(const min_expl&) requires (Mode != 5) = default; + min_expl& operator=(const min_expl&) + requires(Mode != 5) + = default; // move assignment - min_expl& operator=(min_expl&&) requires (Mode != 6) = default; - min_expl& operator=(min_expl&&) requires (Mode == 6) = delete; + min_expl& operator=(min_expl&&) + requires(Mode != 6) + = default; + min_expl& operator=(min_expl&&) + requires(Mode == 6) + = delete; // equality - [[nodiscard]] bool operator==(const min_expl&) const requires (Mode != 7) = default; + [[nodiscard]] bool operator==(const min_expl&) const + requires(Mode != 7) + = default; // scalability - multiplication - [[nodiscard]] friend constexpr min_expl operator*(const min_expl& lhs, const min_expl& rhs) requires (Mode != 8) - { return min_expl(lhs.value_ * rhs.value_); } + [[nodiscard]] friend constexpr min_expl operator*(const min_expl& lhs, const min_expl& rhs) + requires(Mode != 8) + { + return min_expl(lhs.value_ * rhs.value_); + } // scalability - division - [[nodiscard]] friend constexpr min_expl operator/(const min_expl& lhs, const min_expl& rhs) requires (Mode != 9) - { return min_expl(lhs.value_ / rhs.value_); } + [[nodiscard]] friend constexpr min_expl operator/(const min_expl& lhs, const min_expl& rhs) + requires(Mode != 9) + { + return min_expl(lhs.value_ / rhs.value_); + } }; -} +} // namespace template struct std::common_type> : std::type_identity> {}; @@ -161,53 +187,57 @@ static_assert(!Representation>); // quantity's operators should mirror the representation type capabilities template concept invalid_member_operations = requires(length lhs) { - requires !requires { +lhs; }; - requires !requires { -lhs; }; - requires !requires { ++lhs; }; - requires !requires { lhs++; }; - requires !requires { --lhs; }; - requires !requires { lhs--; }; + requires !requires { +lhs; }; + requires !requires { -lhs; }; + requires !requires { ++lhs; }; + requires !requires { lhs++; }; + requires !requires { --lhs; }; + requires !requires { lhs--; }; - requires !requires(length rhs) { lhs += rhs; }; - requires !requires(length rhs) { lhs -= rhs; }; - requires !requires(Rep rhs) { lhs *= rhs; }; - requires !requires(Rep rhs) { lhs /= rhs; }; - requires !requires(Rep rhs) { lhs %= rhs; }; - requires !requires(length rhs) { lhs %= rhs; }; + requires !requires(length rhs) { lhs += rhs; }; + requires !requires(length rhs) { lhs -= rhs; }; + requires !requires(Rep rhs) { lhs *= rhs; }; + requires !requires(Rep rhs) { lhs /= rhs; }; + requires !requires(Rep rhs) { lhs %= rhs; }; + requires !requires(length rhs) { lhs %= rhs; }; - requires !requires(length rhs) { lhs + rhs; }; - requires !requires(length rhs) { lhs - rhs; }; - requires !requires(Rep rhs) { lhs % rhs; }; - requires !requires(length rhs) { lhs % rhs; }; - requires !requires(length rhs) { lhs < rhs; }; - requires !requires(length rhs) { lhs > rhs; }; - requires !requires(length rhs) { lhs <= rhs; }; - requires !requires(length rhs) { lhs >= rhs; }; + requires !requires(length rhs) { lhs + rhs; }; + requires !requires(length rhs) { lhs - rhs; }; + requires !requires(Rep rhs) { lhs % rhs; }; + requires !requires(length rhs) { lhs % rhs; }; + requires !requires(length rhs) { lhs < rhs; }; + requires !requires(length rhs) { lhs > rhs; }; + requires !requires(length rhs) { lhs <= rhs; }; + requires !requires(length rhs) { lhs >= rhs; }; - requires !requires(length rhs) { lhs + rhs; }; - requires !requires(length rhs) { lhs - rhs; }; - requires !requires(int rhs) { lhs % rhs; }; - requires !requires(length rhs) { lhs % rhs; }; - requires !requires(length rhs) { lhs == rhs; }; - requires !requires(length rhs) { lhs != rhs; }; - requires !requires(length rhs) { lhs < rhs; }; - requires !requires(length rhs) { lhs > rhs; }; - requires !requires(length rhs) { lhs <= rhs; }; - requires !requires(length rhs) { lhs >= rhs; }; + requires !requires(length rhs) { lhs + rhs; }; + requires !requires(length rhs) { lhs - rhs; }; + requires !requires(int rhs) { lhs % rhs; }; + requires !requires(length rhs) { lhs % rhs; }; + requires !requires(length rhs) { lhs == rhs; }; + requires !requires(length rhs) { lhs != rhs; }; + requires !requires(length rhs) { lhs < rhs; }; + requires !requires(length rhs) { lhs > rhs; }; + requires !requires(length rhs) { lhs <= rhs; }; + requires !requires(length rhs) { lhs >= rhs; }; - requires !requires(std::ostream os) { os << lhs; }; -}; + requires !requires(std::ostream os) { os << lhs; }; + }; static_assert(invalid_member_operations>); // equality static_assert(length>(min_expl(2)) == length>(min_expl(2000))); static_assert(length>(min_expl(123)) * min_expl(2) == length>(min_expl(246))); -static_assert(length>(min_expl(123)) * quantity{min_expl(2)} == length>(min_expl(246))); +static_assert(length>(min_expl(123)) * quantity{min_expl(2)} == + length>(min_expl(246))); static_assert(min_expl(2) * length>(min_expl(123)) == length>(min_expl(246))); -static_assert(quantity{min_expl(2)} * length>(min_expl(123)) == length>(min_expl(246))); +static_assert(quantity{min_expl(2)} * length>(min_expl(123)) == + length>(min_expl(246))); static_assert(length>(min_expl(246)) / min_expl(2) == length>(min_expl(123))); -static_assert(length>(min_expl(246)) / quantity{min_expl(2)} == length>(min_expl(123))); -static_assert(length>(min_expl(246)) / length>(min_expl(2)) == quantity{min_expl(123)}); +static_assert(length>(min_expl(246)) / quantity{min_expl(2)} == + length>(min_expl(123))); +static_assert(length>(min_expl(246)) / length>(min_expl(2)) == + quantity{min_expl(123)}); static_assert(length>(min_expl(246)) / length>(min_expl(2)) == min_expl(123)); } // namespace diff --git a/test/unit_test/static/custom_rep_test_min_impl.cpp b/test/unit_test/static/custom_rep_test_min_impl.cpp index 093b037c..62b1ceb2 100644 --- a/test/unit_test/static/custom_rep_test_min_impl.cpp +++ b/test/unit_test/static/custom_rep_test_min_impl.cpp @@ -28,9 +28,9 @@ namespace { /** * @brief Implicitly constructible and convertible representation type - * + * * A wrapper type that is implicitly convertible from and to the contained type. - * + * * @tparam T element type */ template @@ -42,11 +42,13 @@ public: min_impl() = default; constexpr min_impl(T v) noexcept : value_(v) {} template - constexpr min_impl(min_impl i) noexcept : value_(static_cast(i.value_)) {} + constexpr min_impl(min_impl i) noexcept : value_(static_cast(i.value_)) + { + } constexpr operator T() const noexcept { return value_; } }; -} +} // namespace template struct std::common_type, min_impl> : std::common_type {}; @@ -125,7 +127,8 @@ static_assert(!std::convertible_to, dimensionless>, min_impl>); static_assert(!std::convertible_to, dimensionless>>); -static_assert(!std::constructible_from>, min_impl>); // narrowing conversion +static_assert( + !std::constructible_from>, min_impl>); // narrowing conversion static_assert(!std::convertible_to, dimensionless>>); // implicit conversion tests @@ -191,7 +194,8 @@ static_assert(std::convertible_to>, length>, length>>); static_assert(std::convertible_to>, length>>); -static_assert(!std::constructible_from>, length>>); // narrowing conversion +static_assert( + !std::constructible_from>, length>>); // narrowing conversion static_assert(!std::convertible_to>, length>>); // T -> min_impl @@ -204,7 +208,7 @@ static_assert(std::convertible_to, length>, length>); static_assert(std::convertible_to, length>>); -static_assert(!std::constructible_from>, length>); // narrowing conversion +static_assert(!std::constructible_from>, length>); // narrowing conversion static_assert(!std::convertible_to, length>>); // min_impl -> T @@ -217,13 +221,14 @@ static_assert(std::convertible_to>, length, length>>); static_assert(std::convertible_to>, length>); -static_assert(!std::constructible_from, length>>); // narrowing conversion +static_assert(!std::constructible_from, length>>); // narrowing conversion static_assert(!std::convertible_to>, length>); // arithmetic operators static_assert(length>(1) + length>(1) == length>(2)); -static_assert(length>(1) + length>(1.5) == length>(2.5)); +static_assert(length>(1) + length>(1.5) == + length>(2.5)); static_assert(length(1) + length>(1) == length>(2)); static_assert(length(1) + length>(1.5) == length>(2.5)); static_assert(length>(1) + length(1) == length>(2)); @@ -231,26 +236,37 @@ static_assert(length>(1) + length(1.5) == le static_assert(length>(1) + length>(1) == length(2)); static_assert(length>(1) + length>(1.5) == length(2.5)); -static_assert(length>(1) + length>(1) == length>(1001)); -static_assert(length>(1) + length>(1.5) == length>(1001.5)); +static_assert(length>(1) + length>(1) == + length>(1001)); +static_assert(length>(1) + length>(1.5) == + length>(1001.5)); static_assert(length(1) + length>(1) == length>(1001)); -static_assert(length(1) + length>(1.5) == length>(1001.5)); +static_assert(length(1) + length>(1.5) == + length>(1001.5)); static_assert(length>(1) + length(1) == length>(1001)); -static_assert(length>(1) + length(1.5) == length>(1001.5)); +static_assert(length>(1) + length(1.5) == + length>(1001.5)); static_assert(length>(1) + length>(1) == length(1001)); -static_assert(length>(1) + length>(1.5) == length(1001.5)); +static_assert(length>(1) + length>(1.5) == + length(1001.5)); -static_assert(length>(1) + length>(1) == length>(1001)); -static_assert(length>(1) + length>(1.5) == length>(1501)); +static_assert(length>(1) + length>(1) == + length>(1001)); +static_assert(length>(1) + length>(1.5) == + length>(1501)); static_assert(length(1) + length>(1) == length>(1001)); -static_assert(length(1) + length>(1.5) == length>(1501)); +static_assert(length(1) + length>(1.5) == + length>(1501)); static_assert(length>(1) + length(1) == length>(1001)); -static_assert(length>(1) + length(1.5) == length>(1501)); +static_assert(length>(1) + length(1.5) == + length>(1501)); static_assert(length>(1) + length>(1) == length(1001)); -static_assert(length>(1) + length>(1.5) == length(1501)); +static_assert(length>(1) + length>(1.5) == + length(1501)); static_assert(length>(2) - length>(1) == length>(1)); -static_assert(length>(2) - length>(1.5) == length>(0.5)); +static_assert(length>(2) - length>(1.5) == + length>(0.5)); static_assert(length(2) - length>(1) == length>(1)); static_assert(length(2) - length>(1.5) == length>(0.5)); static_assert(length>(2) - length(1) == length>(1)); @@ -258,29 +274,40 @@ static_assert(length>(2) - length(1.5) == le static_assert(length>(2) - length>(1) == length(1)); static_assert(length>(2) - length>(1.5) == length(0.5)); -static_assert(length>(2) - length>(1) == length>(1999)); -static_assert(length>(2) - length>(1.5) == length>(1998.5)); +static_assert(length>(2) - length>(1) == + length>(1999)); +static_assert(length>(2) - length>(1.5) == + length>(1998.5)); static_assert(length(2) - length>(1) == length>(1999)); -static_assert(length(2) - length>(1.5) == length>(1998.5)); +static_assert(length(2) - length>(1.5) == + length>(1998.5)); static_assert(length>(2) - length(1) == length>(1999)); -static_assert(length>(2) - length(1.5) == length>(1998.5)); +static_assert(length>(2) - length(1.5) == + length>(1998.5)); static_assert(length>(2) - length>(1) == length(1999)); -static_assert(length>(2) - length>(1.5) == length(1998.5)); +static_assert(length>(2) - length>(1.5) == + length(1998.5)); -static_assert(length>(2000) - length>(1) == length>(1000)); -static_assert(length>(2000) - length>(1.5) == length>(500)); +static_assert(length>(2000) - length>(1) == + length>(1000)); +static_assert(length>(2000) - length>(1.5) == + length>(500)); static_assert(length(2000) - length>(1) == length>(1000)); -static_assert(length(2000) - length>(1.5) == length>(500)); +static_assert(length(2000) - length>(1.5) == + length>(500)); static_assert(length>(2000) - length(1) == length>(1000)); -static_assert(length>(2000) - length(1.5) == length>(500)); +static_assert(length>(2000) - length(1.5) == + length>(500)); static_assert(length>(2000) - length>(1) == length(1000)); -static_assert(length>(2000) - length>(1.5) == length(500)); +static_assert(length>(2000) - length>(1.5) == + length(500)); static_assert(length>(123) * min_impl(1.5) == length>(184.5)); static_assert(length>(123) * 1.5 == length>(184.5)); static_assert(length(123) * min_impl(1.5) == length>(184.5)); -static_assert(length>(123) * quantity{min_impl(1.5)} == length>(184.5)); +static_assert(length>(123) * quantity{min_impl(1.5)} == + length>(184.5)); static_assert(length>(123) * quantity{1.5} == length>(184.5)); static_assert(length(123) * quantity{min_impl(1.5)} == length>(184.5)); @@ -288,7 +315,8 @@ static_assert(min_impl(1.5) * length>(123) == lengt static_assert(min_impl(1.5) * length(123) == length>(184.5)); static_assert(1.5 * length>(123) == length>(184.5)); -static_assert(quantity{min_impl(1.5)} * length>(123) == length>(184.5)); +static_assert(quantity{min_impl(1.5)} * length>(123) == + length>(184.5)); static_assert(quantity{min_impl(1.5)} * length(123) == length>(184.5)); static_assert(quantity{1.5} * length>(123) == length>(184.5)); @@ -296,7 +324,8 @@ static_assert(length>(123) / min_impl(2.) == length static_assert(length>(123) / 2. == length>(61.5)); static_assert(length(123) / min_impl(2.) == length>(61.5)); -static_assert(length>(123) / quantity{min_impl(2.)} == length>(61.5)); +static_assert(length>(123) / quantity{min_impl(2.)} == + length>(61.5)); static_assert(length>(123) / quantity{2.} == length>(61.5)); static_assert(length(123) / quantity{min_impl(2.)} == length>(61.5)); diff --git a/test/unit_test/static/custom_unit_test.cpp b/test/unit_test/static/custom_unit_test.cpp index ecb68b09..9ea04d20 100644 --- a/test/unit_test/static/custom_unit_test.cpp +++ b/test/unit_test/static/custom_unit_test.cpp @@ -27,7 +27,7 @@ #include #include #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include namespace { @@ -37,35 +37,43 @@ using namespace units::isq::si; // power spectral density struct sq_volt_per_hertz : unit {}; -struct dim_power_spectral_density : derived_dimension, units::exponent> {}; +struct dim_power_spectral_density : + derived_dimension, + units::exponent> {}; template U, Representation Rep = double> using power_spectral_density = quantity; // amplitude spectral density struct volt_per_sqrt_hertz : unit {}; -struct dim_amplitude_spectral_density : derived_dimension, units::exponent> {}; +struct dim_amplitude_spectral_density : + derived_dimension, + units::exponent> {}; template U, Representation Rep = double> using amplitude_spectral_density = quantity; -} +} // namespace namespace { static_assert(compare, dim_amplitude_spectral_density>); static_assert(compare, dim_power_spectral_density>); -static_assert(compare(amplitude_spectral_density(4))), decltype(power_spectral_density(16))>); -static_assert(compare(16))), decltype(amplitude_spectral_density(4))>); +static_assert(compare(amplitude_spectral_density(4))), + decltype(power_spectral_density(16))>); +static_assert(compare(16))), + decltype(amplitude_spectral_density(4))>); -} +} // namespace namespace { struct kilogram_per_second : unit {}; -struct dim_mass_rate : derived_dimension, units::exponent> {}; +struct dim_mass_rate : + derived_dimension, units::exponent> { +}; struct kilogram_per_hour : derived_unit {}; [[maybe_unused]] constexpr auto a = 1_q_kg / 1_q_h; -} +} // namespace diff --git a/test/unit_test/static/dimension_op_test.cpp b/test/unit_test/static/dimension_op_test.cpp index 64daefbd..61de01f9 100644 --- a/test/unit_test/static/dimension_op_test.cpp +++ b/test/unit_test/static/dimension_op_test.cpp @@ -20,9 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include #include #include +#include #include #include @@ -54,18 +54,21 @@ using derived_dim = detail::derived_dimension_base; static_assert(is_same_v, exponent_list<>>); static_assert(is_same_v>, exponent_list>>); -static_assert(is_same_v, units::exponent>, exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>, + exponent_list, units::exponent>>); using dim1 = derived_dim>; using dim2 = derived_dim, units::exponent>; -static_assert(is_same_v, units::exponent>, exponent_list, units::exponent>>); +static_assert(is_same_v, units::exponent>, + exponent_list, units::exponent>>); static_assert(is_same_v, units::exponent, units::exponent>, - exponent_list, units::exponent, units::exponent, units::exponent>>); + exponent_list, units::exponent, units::exponent, + units::exponent>>); // dim_invert static_assert(is_same_v>>, d0>); static_assert(is_same_v>>, unknown_dimension>>); -static_assert( - is_same_v, units::exponent>>, unknown_dimension, units::exponent>>); +static_assert(is_same_v, units::exponent>>, + unknown_dimension, units::exponent>>); // make_dimension @@ -73,46 +76,63 @@ template using make_dimension = detail::make_dimension; static_assert(is_same_v>, derived_dim>>); -static_assert(is_same_v, units::exponent>, derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent>, derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent>, derived_dim>>); +static_assert(is_same_v, units::exponent>, + derived_dim, units::exponent>>); +static_assert(is_same_v, units::exponent>, + derived_dim, units::exponent>>); +static_assert( + is_same_v, units::exponent>, derived_dim>>); +static_assert( + is_same_v, units::exponent>, derived_dim>>); +static_assert( + is_same_v, units::exponent>, derived_dim>>); +static_assert( + is_same_v, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent, units::exponent, units::exponent>, - derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent, units::exponent, units::exponent>, - derived_dim, units::exponent>>); +static_assert(is_same_v, units::exponent, units::exponent, + units::exponent>, + derived_dim, units::exponent>>); +static_assert(is_same_v, units::exponent, units::exponent, + units::exponent>, + derived_dim, units::exponent>>); -static_assert(is_same_v, units::exponent, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent, units::exponent>, derived_dim>>); -static_assert(is_same_v, units::exponent, units::exponent>, derived_dim>>); +static_assert(is_same_v, units::exponent, units::exponent>, + derived_dim>>); +static_assert(is_same_v, units::exponent, units::exponent>, + derived_dim>>); +static_assert(is_same_v, units::exponent, units::exponent>, + derived_dim>>); // dimension_multiply static_assert(is_same_v>, derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert( - is_same_v>, d1>, unknown_dimension, units::exponent>>); -static_assert( - is_same_v>>, unknown_dimension, units::exponent>>); + unknown_dimension, units::exponent>>); +static_assert(is_same_v>, d1>, + unknown_dimension, units::exponent>>); +static_assert(is_same_v>>, + unknown_dimension, units::exponent>>); static_assert(is_same_v, unknown_dimension, units::exponent>>); -static_assert(is_same_v< - dimension_multiply, units::exponent, units::exponent>, derived_dim>>, - unknown_dimension, units::exponent, units::exponent, units::exponent>>); -static_assert(is_same_v< - dimension_multiply, units::exponent, units::exponent>, derived_dim>>, - unknown_dimension, units::exponent, units::exponent>>); -static_assert(is_same_v< - dimension_multiply, units::exponent, units::exponent>, derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert(is_same_v>, derived_dim>>, d0>); +static_assert( + is_same_v< + dimension_multiply, units::exponent, units::exponent>, + derived_dim>>, + unknown_dimension, units::exponent, units::exponent, units::exponent>>); +static_assert( + is_same_v, units::exponent, units::exponent>, + derived_dim>>, + unknown_dimension, units::exponent, units::exponent>>); +static_assert( + is_same_v, units::exponent, units::exponent>, + derived_dim>>, + unknown_dimension, units::exponent>>); +static_assert( + is_same_v>, derived_dim>>, d0>); // dimension_divide static_assert(is_same_v>, derived_dim>>, - unknown_dimension, units::exponent>>); -static_assert(is_same_v>, unknown_dimension>>, d0>); + unknown_dimension, units::exponent>>); +static_assert( + is_same_v>, unknown_dimension>>, d0>); } // namespace diff --git a/test/unit_test/static/iec80000_test.cpp b/test/unit_test/static/iec80000_test.cpp index c947914c..05cf0751 100644 --- a/test/unit_test/static/iec80000_test.cpp +++ b/test/unit_test/static/iec80000_test.cpp @@ -58,4 +58,4 @@ static_assert(120 * kB / (2 * min) == 1000 * (B / s)); static_assert(12 / (2 * s) == 6 * Bd); static_assert(6000 / (3 * s) == 2 * kBd); -} +} // namespace diff --git a/test/unit_test/static/math_test.cpp b/test/unit_test/static/math_test.cpp index f2a5b683..02339c8c 100644 --- a/test/unit_test/static/math_test.cpp +++ b/test/unit_test/static/math_test.cpp @@ -21,14 +21,14 @@ // SOFTWARE. #include "test_tools.h" -#include // IWYU pragma: keep -#include #include -#include -#include -#include #include +#include #include +#include +#include +#include +#include // IWYU pragma: keep namespace { diff --git a/test/unit_test/static/point_origin_test.cpp b/test/unit_test/static/point_origin_test.cpp index 0b289a75..b302d58a 100644 --- a/test/unit_test/static/point_origin_test.cpp +++ b/test/unit_test/static/point_origin_test.cpp @@ -22,10 +22,10 @@ #include #include +#include +#include #include #include -#include -#include using namespace units; namespace si = isq::si; @@ -54,8 +54,8 @@ static_assert(RebindablePointOriginFor, si::dim_l static_assert(is_same_v, si::dim_length>, dynamic_origin>); static_assert(RebindablePointOriginFor, si::dim_time>); -static_assert(is_same_v, si::dim_time>, - dynamic_origin>); +static_assert( + is_same_v, si::dim_time>, dynamic_origin>); static_assert(RebindablePointOriginFor); static_assert(is_same_v, ones_viewpoint1>); static_assert(RebindablePointOriginFor); diff --git a/test/unit_test/static/quantity_kind_test.cpp b/test/unit_test/static/quantity_kind_test.cpp index 740d0973..1d9453e0 100644 --- a/test/unit_test/static/quantity_kind_test.cpp +++ b/test/unit_test/static/quantity_kind_test.cpp @@ -62,17 +62,25 @@ struct time_kind : kind {}; struct cgs_width_kind : kind {}; -template using radius = quantity_kind; -template using width = quantity_kind; -template using height = quantity_kind; +template +using radius = quantity_kind; +template +using width = quantity_kind; +template +using height = quantity_kind; -template using horizontal_area = quantity_kind; -template using rate_of_climb = quantity_kind; +template +using horizontal_area = quantity_kind; +template +using rate_of_climb = quantity_kind; -template using apples = quantity_kind; -template using oranges = quantity_kind; +template +using apples = quantity_kind; +template +using oranges = quantity_kind; -template using cgs_width = quantity_kind; +template +using cgs_width = quantity_kind; ///////////// // concepts @@ -102,14 +110,17 @@ static_assert(sizeof(width) == sizeof(double)); static_assert(sizeof(height) == sizeof(short)); template -concept invalid_types = requires { - requires !requires { typename quantity_kind; }; // unit of a different dimension - requires !requires { typename quantity_kind>; }; // quantity used as Rep - requires !requires { typename quantity_kind, metre>>; }; // quantity point used as Rep - requires !requires { typename quantity_kind>; }; // quantity kind used as Rep - requires !requires { typename quantity_kind; }; // reordered arguments - requires !requires { typename quantity_kind; }; // reordered arguments -}; +concept invalid_types = + requires { + requires !requires { typename quantity_kind; }; // unit of a different dimension + requires !requires { typename quantity_kind>; }; // quantity used as Rep + requires !requires { + typename quantity_kind, metre>>; + }; // quantity point used as Rep + requires !requires { typename quantity_kind>; }; // quantity kind used as Rep + requires !requires { typename quantity_kind; }; // reordered arguments + requires !requires { typename quantity_kind; }; // reordered arguments + }; static_assert(invalid_types); static_assert(std::is_trivially_default_constructible_v>); @@ -199,7 +210,7 @@ static_assert(width{}.common() == 0 * m); ///////// static_assert(same(quantity_kind(rate_of_climb(0.01 * (km / h))), - rate_of_climb(0.01 * (km / h)))); + rate_of_climb(0.01 * (km / h)))); //////////////////////////// @@ -417,7 +428,8 @@ static_assert((std::uint8_t(255) * m %= quantity(257)) == (width(255 * m) %= quantity(257)).common()); static_assert((std::uint8_t(255) * m %= 257 * m) == (width(255 * m) %= - quantity_kind, one, std::uint8_t>(257)).common()); + quantity_kind, one, std::uint8_t>(257)) + .common()); static_assert((std::uint8_t(255) * m %= 257 * m) == (width(255 * m) %= width(257 * m)).common()); @@ -425,38 +437,39 @@ static_assert(same((-width(short{1} * m)).common(), int{-1} * m)); template concept invalid_compound_assignments_ = requires(quantity_kind w, Qx q) { - requires !requires { w += q; }; - requires !requires { w -= q; }; - requires !requires { w *= q; }; - requires !requires { w /= q; }; - requires !requires { w %= q; }; -}; + requires !requires { w += q; }; + requires !requires { w -= q; }; + requires !requires { w *= q; }; + requires !requires { w /= q; }; + requires !requires { w %= q; }; + }; template -concept invalid_compound_assignments = requires(quantity_kind w, height h) { - requires !requires { w += 1; }; - requires !requires { w -= 1; }; - requires !requires { w *= 1 * (km / m); }; - requires !requires { w /= 1 * (km / m); }; - requires !requires { w %= 1 * (km / m); }; - requires !requires { w += m; }; - requires !requires { w -= m; }; - requires !requires { w *= m; }; - requires !requires { w /= m; }; - requires !requires { w %= m; }; - requires !requires { w *= quantity_kind, scaled_unit, int>{1}; }; - requires !requires { w /= quantity_kind, scaled_unit, int>{1}; }; - requires !requires { w %= quantity_kind, scaled_unit, int>{1}; }; - requires !requires { w %= 1.0; }; - requires !requires { w %= quantity(1.0); }; - requires !requires { w %= 1.0 * (w / w); }; - requires !requires { w %= 1.0 * w; }; - requires !requires { w %= h / h; }; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_, metre, int>>; - requires invalid_compound_assignments_; -}; +concept invalid_compound_assignments = + requires(quantity_kind w, height h) { + requires !requires { w += 1; }; + requires !requires { w -= 1; }; + requires !requires { w *= 1 * (km / m); }; + requires !requires { w /= 1 * (km / m); }; + requires !requires { w %= 1 * (km / m); }; + requires !requires { w += m; }; + requires !requires { w -= m; }; + requires !requires { w *= m; }; + requires !requires { w /= m; }; + requires !requires { w %= m; }; + requires !requires { w *= quantity_kind, scaled_unit, int>{1}; }; + requires !requires { w /= quantity_kind, scaled_unit, int>{1}; }; + requires !requires { w %= quantity_kind, scaled_unit, int>{1}; }; + requires !requires { w %= 1.0; }; + requires !requires { w %= quantity(1.0); }; + requires !requires { w %= 1.0 * (w / w); }; + requires !requires { w %= 1.0 * w; }; + requires !requires { w %= h / h; }; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_, metre, int>>; + requires invalid_compound_assignments_; + }; static_assert(invalid_compound_assignments); static_assert(invalid_compound_assignments_); @@ -474,14 +487,16 @@ static_assert(same(width(2 * m) - width(3. * m), widt static_assert(same(width(2. * m) - width(3 * m), width(-1. * m))); static_assert(same(width(2e3 * m) - width(3 * km), width(-1e3 * m))); -static_assert(is_same_v< - decltype((width(0 * m) + width(0 * m)).common().number()), int&&>); -static_assert(is_same_v< - decltype((width(0 * m) - width(0 * m)).common().number()), int&&>); +static_assert( + is_same_v(0 * m) + width(0 * m)).common().number()), + int&&>); +static_assert( + is_same_v(0 * m) - width(0 * m)).common().number()), + int&&>); static_assert((width(128 * m) + width(128 * m)).common().number() == - std::uint8_t(128) + std::uint8_t(128)); + std::uint8_t(128) + std::uint8_t(128)); static_assert((width(0 * m) - width(1 * m)).common().number() == - std::uint8_t(0) - std::uint8_t(1)); + std::uint8_t(0) - std::uint8_t(1)); static_assert(!std::is_invocable_v, width, double>); static_assert(!std::is_invocable_v, width, length>); @@ -595,15 +610,15 @@ static_assert(same(quantity(2) / quantity_kind(3. * s static_assert(same(quantity(2.) / quantity_kind(3 * s), quantity_kind, hertz, double>(2 / 3. / (1 * s)))); -static_assert( - same(quantity_kind, one, int>(2) / quantity_kind(3 * s), - quantity_kind, hertz, int>(2 / 3 / (1 * s)))); -static_assert( - same(quantity_kind, one, int>(2) / quantity_kind(3. * s), - quantity_kind, hertz, double>(2 / 3. / (1 * s)))); -static_assert( - same(quantity_kind, one, double>(2.) / quantity_kind(3 * s), - quantity_kind, hertz, double>(2 / 3. / (1 * s)))); +static_assert(same(quantity_kind, one, int>(2) / + quantity_kind(3 * s), + quantity_kind, hertz, int>(2 / 3 / (1 * s)))); +static_assert(same(quantity_kind, one, int>(2) / + quantity_kind(3. * s), + quantity_kind, hertz, double>(2 / 3. / (1 * s)))); +static_assert(same(quantity_kind, one, double>(2.) / + quantity_kind(3 * s), + quantity_kind, hertz, double>(2 / 3. / (1 * s)))); static_assert(same(height(2 * m) / (3 * s), rate_of_climb(0 * (m / s)))); static_assert(same(height(2 * m) / (3. * s), rate_of_climb(2 / 3. * (m / s)))); @@ -611,7 +626,8 @@ static_assert(same(height(2. * m) / (3 * s), rate_of_climb(2 * m) * dimensionless(3), width(6 * cm))); static_assert(same(dimensionless(2) * width(3 * m), width(6 * cm))); -static_assert(same(width(2 * m) / dimensionless(3), width(2. / 3 * hm))); +static_assert(same(width(2 * m) / dimensionless(3), + width(2. / 3 * hm))); static_assert(same(width(2 * m) % dimensionless(3), width(2 * m))); static_assert(same(height(2 * m) / (3 * m), @@ -644,14 +660,16 @@ static_assert(same(horizontal_area(4 * (m * m)) / (1 * m), width(2 * m) % 3, width(2 * m))); static_assert(same(width(3 * m) % width(2 * m), width(1 * m))); -static_assert(is_same_v< - decltype((width(0 * m) % width(0 * m)).common().number()), - decltype(std::uint8_t(0) % std::uint8_t(0))&&>); +static_assert( + is_same_v(0 * m) % width(0 * m)).common().number()), + decltype(std::uint8_t(0) % std::uint8_t(0))&&>); static_assert(!std::is_invocable_v, reference, width>); static_assert(!std::is_invocable_v, width, height>); -static_assert(!std::is_invocable_v, height, quantity_point, metre>>); -static_assert(!std::is_invocable_v, quantity_point, metre>, height>); +static_assert( + !std::is_invocable_v, height, quantity_point, metre>>); +static_assert( + !std::is_invocable_v, quantity_point, metre>, height>); static_assert(!std::is_invocable_v, reference, width>); static_assert(!std::is_invocable_v, width, height>); @@ -660,7 +678,8 @@ static_assert(!std::is_invocable_v, quantity_point, width, reference>); static_assert(!std::is_invocable_v, width, length>); -static_assert(!std::is_invocable_v, width, quantity_point, metre, int>>); +static_assert( + !std::is_invocable_v, width, quantity_point, metre, int>>); static_assert(!std::is_invocable_v, width, double>); static_assert(!std::is_invocable_v, width, width>); @@ -702,24 +721,24 @@ static_assert(std::equality_comparable_with, width, width>); template concept invalid_equality = requires(quantity_kind w) { - requires !requires { w == 1; }; - requires !requires { w != 1.0; }; - requires !requires { w == 1 * m; }; - requires !requires { w != 1.0 * cgs_cm; }; - requires !requires { w == 1 * km; }; - requires !requires { w != m; }; - requires !requires { w == km; }; - requires !requires { w != quantity(1); }; - requires !requires { w == dimensionless(1.0); }; - requires !requires { w != height(1 * m); }; - requires !requires { w == height(1.0 * km); }; - requires !requires { w != horizontal_area(1 * (m * m)); }; - requires !requires { w == rate_of_climb(1.0 * (km / h)); }; - requires !requires { w != quantity_point(1 * m); }; - requires !requires { w == quantity_point(1.0 * mm); }; - requires !requires { w != quantity_point(quantity(1)); }; - requires !requires { w == quantity_point(dimensionless(1.0)); }; -}; + requires !requires { w == 1; }; + requires !requires { w != 1.0; }; + requires !requires { w == 1 * m; }; + requires !requires { w != 1.0 * cgs_cm; }; + requires !requires { w == 1 * km; }; + requires !requires { w != m; }; + requires !requires { w == km; }; + requires !requires { w != quantity(1); }; + requires !requires { w == dimensionless(1.0); }; + requires !requires { w != height(1 * m); }; + requires !requires { w == height(1.0 * km); }; + requires !requires { w != horizontal_area(1 * (m * m)); }; + requires !requires { w == rate_of_climb(1.0 * (km / h)); }; + requires !requires { w != quantity_point(1 * m); }; + requires !requires { w == quantity_point(1.0 * mm); }; + requires !requires { w != quantity_point(quantity(1)); }; + requires !requires { w == quantity_point(dimensionless(1.0)); }; + }; static_assert(invalid_equality); static_assert(width(1 * m) < width(2 * m)); @@ -734,22 +753,22 @@ static_assert(std::three_way_comparable_with, width< static_assert(std::three_way_comparable_with, width>); template concept invalid_relational = requires(quantity_kind w) { - requires !requires { w < 1; }; - requires !requires { w <= 1.0; }; - requires !requires { w >= 1 * m; }; - requires !requires { w > 1.0 * cgs_cm; }; - requires !requires { w <=> 1 * km; }; - requires !requires { w < quantity(1); }; - requires !requires { w <= dimensionless(1.0); }; - requires !requires { w >= height(1 * m); }; - requires !requires { w > height(1.0 * km); }; - requires !requires { w <=> horizontal_area(1 * (m * m)); }; - requires !requires { w < rate_of_climb(1.0 * (km / h)); }; - requires !requires { w <= quantity_point(1 * m); }; - requires !requires { w >= quantity_point(1.0 * mm); }; - requires !requires { w > quantity_point(quantity(1)); }; - requires !requires { w <=> quantity_point(dimensionless(1.0)); }; -}; + requires !requires { w < 1; }; + requires !requires { w <= 1.0; }; + requires !requires { w >= 1 * m; }; + requires !requires { w > 1.0 * cgs_cm; }; + requires !requires { w <=> 1 * km; }; + requires !requires { w < quantity(1); }; + requires !requires { w <= dimensionless(1.0); }; + requires !requires { w >= height(1 * m); }; + requires !requires { w > height(1.0 * km); }; + requires !requires { w <=> horizontal_area(1 * (m * m)); }; + requires !requires { w < rate_of_climb(1.0 * (km / h)); }; + requires !requires { w <= quantity_point(1 * m); }; + requires !requires { w >= quantity_point(1.0 * mm); }; + requires !requires { w > quantity_point(quantity(1)); }; + requires !requires { w <=> quantity_point(dimensionless(1.0)); }; + }; static_assert(invalid_relational); @@ -788,22 +807,37 @@ static_assert(same(quantity_kind_cast>(width>(width(1 * cgs_cm)), width(1 * cgs_cm))); // clang-format on template -concept invalid_cast = requires { - requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast, metre, int>>(quantity_kind(1 * m)); }; - requires !requires { quantity_kind_cast, one, int>>(quantity_kind(1 * m)); }; -}; +concept invalid_cast = + requires { + requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; + requires !requires { + quantity_kind_cast>(quantity_kind(1 * m)); + }; + requires !requires { + quantity_kind_cast>(quantity_kind(1 * m)); + }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { + quantity_kind_cast(quantity_kind(1 * m)); + }; + requires !requires { + quantity_kind_cast(quantity_kind(1 * m)); + }; + requires !requires { quantity_kind_cast>(quantity_kind(1 * m)); }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { quantity_kind_cast(quantity_kind(1 * m)); }; + requires !requires { + quantity_kind_cast, metre, int>>( + quantity_kind(1 * m)); + }; + requires !requires { + quantity_kind_cast, one, int>>( + quantity_kind(1 * m)); + }; + }; static_assert(invalid_cast); @@ -817,15 +851,15 @@ struct radius_kind : kind {}; struct cylinder_size {}; -template Radius, units::QuantityKindOf Height> +template Radius, units::QuantityKindOf Height> cylinder_size operator+(Radius, Height); } // namespace mylib namespace yourapp { -static_assert(is_same_v(1. * m) + height(1. * m))>); +static_assert(is_same_v(1. * m) + + height(1. * m))>); } // namespace yourapp diff --git a/test/unit_test/static/quantity_point_kind_test.cpp b/test/unit_test/static/quantity_point_kind_test.cpp index 73738566..ab6e3cb6 100644 --- a/test/unit_test/static/quantity_point_kind_test.cpp +++ b/test/unit_test/static/quantity_point_kind_test.cpp @@ -79,16 +79,25 @@ struct time_point_kind : point_kind {}; struct sys_time_point_kind : point_kind> {}; -template using width = quantity_kind; -template using height = quantity_kind; -template using abscissa = quantity_point_kind; -template using ordinate = quantity_point_kind; +template +using width = quantity_kind; +template +using height = quantity_kind; +template +using abscissa = quantity_point_kind; +template +using ordinate = quantity_point_kind; -template using distance = quantity_kind; -template using cgs_width = quantity_kind; -template using cgs_height = quantity_kind; -template using rate_of_climb = quantity_kind; -template using altitude = quantity_point_kind; +template +using distance = quantity_kind; +template +using cgs_width = quantity_kind; +template +using cgs_height = quantity_kind; +template +using rate_of_climb = quantity_kind; +template +using altitude = quantity_point_kind; template using sea_level_altitude = quantity_point_kind; @@ -97,10 +106,14 @@ using screen_si_width = quantity_point_kind; template using screen_si_cgs_width = quantity_point_kind; -template using apples = quantity_kind; -template using oranges = quantity_kind; -template using nth_apple = quantity_point_kind; -template using nth_orange = quantity_point_kind; +template +using apples = quantity_kind; +template +using oranges = quantity_kind; +template +using nth_apple = quantity_point_kind; +template +using nth_orange = quantity_point_kind; ///////////// // concepts @@ -137,16 +150,21 @@ static_assert(sizeof(abscissa) == sizeof(double)); static_assert(sizeof(ordinate) == sizeof(short)); template -concept invalid_types = requires { - requires !requires { typename quantity_point_kind; }; // width_kind is not a point kind - requires !requires { typename quantity_point_kind; }; // unit of a different dimension - requires !requires { typename quantity_point_kind>; }; // quantity used as Rep - requires !requires { typename quantity_point_kind, metre>>; }; // quantity point used as Rep - requires !requires { typename quantity_point_kind>; }; // quantity kind used as Rep - requires !requires { typename quantity_point_kind>; }; // quantity point kind used as Rep - requires !requires { typename quantity_point_kind; }; // reordered arguments - requires !requires { typename quantity_point_kind; }; // reordered arguments -}; +concept invalid_types = + requires { + requires !requires { typename quantity_point_kind; }; // width_kind is not a point kind + requires !requires { typename quantity_point_kind; }; // unit of a different dimension + requires !requires { typename quantity_point_kind>; }; // quantity used as Rep + requires !requires { + typename quantity_point_kind, metre>>; + }; // quantity point used as Rep + requires !requires { typename quantity_point_kind>; }; // quantity kind used as Rep + requires !requires { + typename quantity_point_kind>; + }; // quantity point kind used as Rep + requires !requires { typename quantity_point_kind; }; // reordered arguments + requires !requires { typename quantity_point_kind; }; // reordered arguments + }; static_assert(invalid_types); static_assert(std::is_trivially_default_constructible_v>); @@ -456,22 +474,23 @@ static_assert([]() { template concept invalid_compound_assignments_ = requires(quantity_point_kind x, Qx q) { - requires !requires { x += q; }; - requires !requires { x -= q; }; -}; + requires !requires { x += q; }; + requires !requires { x -= q; }; + }; template -concept invalid_compound_assignments = requires(quantity_point_kind x) { - requires !requires { x += 1; }; - requires !requires { x -= 1; }; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_>; - requires invalid_compound_assignments_, metre, int>>; - requires invalid_compound_assignments_; -}; +concept invalid_compound_assignments = + requires(quantity_point_kind x) { + requires !requires { x += 1; }; + requires !requires { x -= 1; }; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_>; + requires invalid_compound_assignments_, metre, int>>; + requires invalid_compound_assignments_; + }; static_assert(invalid_compound_assignments); static_assert(invalid_compound_assignments_); -#if __cpp_lib_chrono >= 201907L +#if __cpp_lib_chrono >= 201907L static_assert(invalid_compound_assignments_); #endif @@ -545,26 +564,26 @@ static_assert(std::equality_comparable_with, abscissa concept invalid_equality = requires(quantity_point_kind x, Int i) { - requires !requires { x == 1; }; - requires !requires { x != 1.0; }; - requires !requires { x == 1 * m; }; - requires !requires { x != 1.0 * cgs_cm; }; - requires !requires { x == 1 * km; }; - requires !requires { x != quantity(1); }; - requires !requires { x == dimensionless(1.0); }; - requires !requires { x != width(1 * m); }; - requires !requires { x == width(1.0 * km); }; - requires !requires { x != height(1 * m); }; - requires !requires { x == height(1.0 * km); }; - requires !requires { x == rate_of_climb(1.0 * (km / h)); }; - requires !requires { x != quantity_point(1 * m); }; - requires !requires { x == quantity_point(1.0 * mm); }; - requires !requires { x != quantity_point(quantity(1)); }; - requires !requires { x == quantity_point(dimensionless(1.0)); }; - requires !requires { x != quantity_point_kind(cgs_width(1 * m)); }; - requires !requires { x == ordinate(1 * m); }; - requires !requires { screen_si_width{} != screen_si_cgs_width{}; }; -}; + requires !requires { x == 1; }; + requires !requires { x != 1.0; }; + requires !requires { x == 1 * m; }; + requires !requires { x != 1.0 * cgs_cm; }; + requires !requires { x == 1 * km; }; + requires !requires { x != quantity(1); }; + requires !requires { x == dimensionless(1.0); }; + requires !requires { x != width(1 * m); }; + requires !requires { x == width(1.0 * km); }; + requires !requires { x != height(1 * m); }; + requires !requires { x == height(1.0 * km); }; + requires !requires { x == rate_of_climb(1.0 * (km / h)); }; + requires !requires { x != quantity_point(1 * m); }; + requires !requires { x == quantity_point(1.0 * mm); }; + requires !requires { x != quantity_point(quantity(1)); }; + requires !requires { x == quantity_point(dimensionless(1.0)); }; + requires !requires { x != quantity_point_kind(cgs_width(1 * m)); }; + requires !requires { x == ordinate(1 * m); }; + requires !requires { screen_si_width{} != screen_si_cgs_width{}; }; + }; static_assert(invalid_equality); // clang-format off @@ -580,27 +599,28 @@ static_assert(std::three_way_comparable_with, abs static_assert(std::three_way_comparable_with, abscissa>); // clang-format on template -concept invalid_relational = requires(quantity_point_kind x, Int i) { - requires !requires { x < 1; }; - requires !requires { x <= 1.0; }; - requires !requires { x >= 1 * m; }; - requires !requires { x > 1.0 * cgs_cm; }; - requires !requires { x <=> 1 * km; }; - requires !requires { x < quantity(1); }; - requires !requires { x <= dimensionless(1.0); }; - requires !requires { x >= width(1 * m); }; - requires !requires { x > width(1.0 * km); }; - requires !requires { x <=> height(1 * m); }; - requires !requires { x < height(1.0 * km); }; - requires !requires { x <= rate_of_climb(1.0 * (km / h)); }; - requires !requires { x >= quantity_point(1 * m); }; - requires !requires { x > quantity_point(1.0 * mm); }; - requires !requires { x <=> quantity_point(quantity(1)); }; - requires !requires { x < quantity_point(dimensionless(1.0)); }; - requires !requires { x <= quantity_point_kind(cgs_width(1 * m)); }; - requires !requires { x >= ordinate(1 * m); }; - requires !requires { screen_si_width{} > screen_si_cgs_width{}; }; -}; +concept invalid_relational = + requires(quantity_point_kind x, Int i) { + requires !requires { x < 1; }; + requires !requires { x <= 1.0; }; + requires !requires { x >= 1 * m; }; + requires !requires { x > 1.0 * cgs_cm; }; + requires !requires { x <=> 1 * km; }; + requires !requires { x < quantity(1); }; + requires !requires { x <= dimensionless(1.0); }; + requires !requires { x >= width(1 * m); }; + requires !requires { x > width(1.0 * km); }; + requires !requires { x <=> height(1 * m); }; + requires !requires { x < height(1.0 * km); }; + requires !requires { x <= rate_of_climb(1.0 * (km / h)); }; + requires !requires { x >= quantity_point(1 * m); }; + requires !requires { x > quantity_point(1.0 * mm); }; + requires !requires { x <=> quantity_point(quantity(1)); }; + requires !requires { x < quantity_point(dimensionless(1.0)); }; + requires !requires { x <= quantity_point_kind(cgs_width(1 * m)); }; + requires !requires { x >= ordinate(1 * m); }; + requires !requires { screen_si_width{} > screen_si_cgs_width{}; }; + }; static_assert(invalid_relational); @@ -652,25 +672,35 @@ static_assert(same(quantity_point_kind_cast>(abscissa>(screen_si_width(1 * m)), screen_si_cgs_width(1 * m))); // clang-format on template -concept invalid_cast = requires(Int i) { - requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast, metre, Int>>(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast, one, Int>>(abscissa(i * m)); }; - requires !requires { quantity_point_kind_cast, metre, Int>>(screen_si_width(i * m)); }; -}; +concept invalid_cast = + requires(Int i) { + requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast>(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { quantity_point_kind_cast(abscissa(i * m)); }; + requires !requires { + quantity_point_kind_cast, metre, Int>>( + abscissa(i * m)); + }; + requires !requires { + quantity_point_kind_cast, one, Int>>( + abscissa(i * m)); + }; + requires !requires { + quantity_point_kind_cast, metre, Int>>( + screen_si_width(i * m)); + }; + }; static_assert(invalid_cast); @@ -687,16 +717,16 @@ struct ordinate_kind : point_kind {}; struct point {}; -template Abscissa, units::QuantityPointKindOf Ordinate> +template Abscissa, units::QuantityPointKindOf Ordinate> point operator+(Abscissa, Ordinate); } // namespace mylib namespace yourapp { -static_assert(is_same_v(1 * m)) + - quantity_point_kind(quantity_kind(1 * m)))>); +static_assert( + is_same_v(1 * m)) + + quantity_point_kind(quantity_kind(1 * m)))>); } // namespace yourapp diff --git a/test/unit_test/static/test_tools.h b/test/unit_test/static/test_tools.h index 8ddfbca9..70ef41a1 100644 --- a/test/unit_test/static/test_tools.h +++ b/test/unit_test/static/test_tools.h @@ -34,24 +34,27 @@ template inline constexpr bool compare_impl = true; template - requires (UNITS_DOWNCAST_MODE == 0) + requires(UNITS_DOWNCAST_MODE == 0) inline constexpr bool compare_impl = units::equivalent; template inline constexpr bool compare = compare_impl, std::remove_cvref_t>; template -constexpr bool constructible_from(Vs...) { +constexpr bool constructible_from(Vs...) +{ return std::constructible_from; } -template void convertible_from__(T); +template +void convertible_from__(T); template concept convertible_from_ = requires(Us... us) { convertible_from__({us...}); }; template -constexpr bool convertible_from(Vs...) { +constexpr bool convertible_from(Vs...) +{ if constexpr (sizeof...(Us) + sizeof...(Vs) == 1) return std::is_convertible_v; else @@ -59,24 +62,28 @@ constexpr bool convertible_from(Vs...) { } template -constexpr bool constructible_or_convertible_from(Vs...) { +constexpr bool constructible_or_convertible_from(Vs...) +{ return constructible_from() || convertible_from(); } template -constexpr bool constructible_and_convertible_from(Vs...) { +constexpr bool constructible_and_convertible_from(Vs...) +{ return constructible_from() && convertible_from(); } template - requires (constructible_from()) -constexpr T construct_from(Us... us) { + requires(constructible_from()) +constexpr T construct_from(Us... us) +{ return T(us...); } template - requires (convertible_from()) -constexpr T convert_from(Us... us) { + requires(convertible_from()) +constexpr T convert_from(Us... us) +{ if constexpr (sizeof...(Us) == 1) return [](T t) { return t; }(us...); else @@ -84,16 +91,18 @@ constexpr T convert_from(Us... us) { } template - requires (constructible_from() && convertible_from()) -constexpr T construct_and_convert_from(Us... us) { + requires(constructible_from() && convertible_from()) +constexpr T construct_and_convert_from(Us... us) +{ T t{construct_from(us...)}; assert(t == convert_from(us...)); return t; } template - requires (constructible_from() && !convertible_from()) -constexpr T construct_from_only(Us... us) { + requires(constructible_from() && !convertible_from()) +constexpr T construct_from_only(Us... us) +{ return construct_from(us...); } @@ -109,7 +118,8 @@ inline constexpr bool ctad_constructible_from_ typename T, typename... Us, typename... Vs> -constexpr bool ctad_constructible_from(Vs...) { +constexpr bool ctad_constructible_from(Vs...) +{ return ctad_constructible_from_; } @@ -118,8 +128,10 @@ constexpr auto same = [](T l, T r) { return l == r; #else constexpr auto same = [](T l, U r) requires requires { l == r; } - // requires std::equality_comparable_with // TODO: Fix #205 - { return l == r; }; +// requires std::equality_comparable_with // TODO: Fix #205 +{ + return l == r; +}; #endif template