From fb97c2ea5a356f206dbf306339a2b7b7e9708b18 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Mon, 18 Mar 2024 23:12:39 +0900 Subject: [PATCH] refactor: `basic_symbol_text` renamed to `symbol_text` --- .../framework_basics/text_output.md | 4 +- .../mp-units/bits/dimension_concepts.h | 6 +-- src/core/include/mp-units/bits/magnitude.h | 16 +++---- src/core/include/mp-units/bits/symbol_text.h | 35 +++++++------- src/core/include/mp-units/bits/text_tools.h | 20 ++++---- .../include/mp-units/bits/unit_concepts.h | 14 +++--- src/core/include/mp-units/dimension.h | 2 +- src/core/include/mp-units/unit.h | 34 +++++++------- .../include/mp-units/systems/angular/units.h | 4 +- .../include/mp-units/systems/iau/iau.h | 8 ++-- .../mp-units/systems/isq/base_quantities.h | 2 +- .../include/mp-units/systems/si/constants.h | 6 +-- .../include/mp-units/systems/si/prefixes.h | 2 +- .../include/mp-units/systems/si/units.h | 10 ++-- .../include/mp-units/systems/usc/usc.h | 2 +- test/static/symbol_text_test.cpp | 46 +++++++++---------- test/static/unit_test.cpp | 12 ++--- 17 files changed, 110 insertions(+), 113 deletions(-) diff --git a/docs/users_guide/framework_basics/text_output.md b/docs/users_guide/framework_basics/text_output.md index edd38fbc..365b8ece 100644 --- a/docs/users_guide/framework_basics/text_output.md +++ b/docs/users_guide/framework_basics/text_output.md @@ -101,11 +101,11 @@ and units of derived quantities. !!! tip - For older compilers, it might be required to specify a `basic_symbol_text` class explicitly + For older compilers, it might be required to specify a `symbol_text` class explicitly template name to initialize it with two symbols: ```cpp - inline constexpr struct ohm : named_unit {} ohm; + inline constexpr struct ohm : named_unit {} ohm; ``` diff --git a/src/core/include/mp-units/bits/dimension_concepts.h b/src/core/include/mp-units/bits/dimension_concepts.h index 56e64d1b..b458ae5f 100644 --- a/src/core/include/mp-units/bits/dimension_concepts.h +++ b/src/core/include/mp-units/bits/dimension_concepts.h @@ -29,12 +29,12 @@ namespace mp_units { -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template struct base_dimension; namespace detail { -template +template void to_base_specialization_of_base_dimension(const volatile base_dimension*); template @@ -44,7 +44,7 @@ inline constexpr bool is_derived_from_specialization_of_base_dimension = template inline constexpr bool is_specialization_of_base_dimension = false; -template +template inline constexpr bool is_specialization_of_base_dimension> = true; /** diff --git a/src/core/include/mp-units/bits/magnitude.h b/src/core/include/mp-units/bits/magnitude.h index 7fa09d94..3b0f7648 100644 --- a/src/core/include/mp-units/bits/magnitude.h +++ b/src/core/include/mp-units/bits/magnitude.h @@ -861,7 +861,7 @@ template return integer_part((detail::abs(power_of_2) < detail::abs(power_of_5)) ? power_of_2 : power_of_5); } -inline constexpr basic_symbol_text base_multiplier(u8"× 10", "x 10"); +inline constexpr symbol_text base_multiplier(u8"× 10", "x 10"); template [[nodiscard]] consteval auto magnitude_text() @@ -880,23 +880,23 @@ template if constexpr (num_value == 1 && den_value == 1 && exp10 != 0) { return base_multiplier + superscript(); } else if constexpr (num_value != 1 || den_value != 1 || exp10 != 0) { - auto txt = basic_symbol_text("[") + regular(); + auto txt = symbol_text("[") + regular(); if constexpr (den_value == 1) { if constexpr (exp10 == 0) { - return txt + basic_symbol_text("]"); + return txt + symbol_text("]"); } else { - return txt + basic_symbol_text(" ") + base_multiplier + superscript() + basic_symbol_text("]"); + return txt + symbol_text(" ") + base_multiplier + superscript() + symbol_text("]"); } } else { if constexpr (exp10 == 0) { - return txt + basic_symbol_text("/") + regular() + basic_symbol_text("]"); + return txt + symbol_text("/") + regular() + symbol_text("]"); } else { - return txt + basic_symbol_text("/") + regular() + basic_symbol_text(" ") + base_multiplier + - superscript() + basic_symbol_text("]"); + return txt + symbol_text("/") + regular() + symbol_text(" ") + base_multiplier + + superscript() + symbol_text("]"); } } } else { - return basic_symbol_text(""); + return symbol_text(""); } } diff --git a/src/core/include/mp-units/bits/symbol_text.h b/src/core/include/mp-units/bits/symbol_text.h index 0588a2c3..9aba2065 100644 --- a/src/core/include/mp-units/bits/symbol_text.h +++ b/src/core/include/mp-units/bits/symbol_text.h @@ -79,36 +79,35 @@ constexpr fixed_u8string to_u8string(fixed_string txt) * @tparam M The size of the ASCII-only symbol */ MP_UNITS_EXPORT template -struct basic_symbol_text { +struct symbol_text { fixed_u8string unicode_; fixed_string ascii_; - constexpr explicit(false) basic_symbol_text(char ch) : unicode_(static_cast(ch)), ascii_(ch) + constexpr explicit(false) symbol_text(char ch) : unicode_(static_cast(ch)), ascii_(ch) { gsl_Expects(detail::is_basic_literal_character_set_char(ch)); } - constexpr explicit(false) basic_symbol_text(const char (&txt)[N + 1]) : + constexpr explicit(false) symbol_text(const char (&txt)[N + 1]) : unicode_(detail::to_u8string(basic_fixed_string{txt})), ascii_(txt) { gsl_ExpectsAudit(txt[N] == char{}); gsl_Expects(detail::is_basic_literal_character_set(txt)); } - constexpr explicit(false) basic_symbol_text(const fixed_string& txt) : - unicode_(detail::to_u8string(txt)), ascii_(txt) + constexpr explicit(false) symbol_text(const fixed_string& txt) : unicode_(detail::to_u8string(txt)), ascii_(txt) { gsl_Expects(detail::is_basic_literal_character_set(txt.data_)); } - constexpr basic_symbol_text(const char8_t (&u)[N + 1], const char (&a)[M + 1]) : unicode_(u), ascii_(a) + constexpr symbol_text(const char8_t (&u)[N + 1], const char (&a)[M + 1]) : unicode_(u), ascii_(a) { gsl_ExpectsAudit(u[N] == char8_t{}); gsl_ExpectsAudit(a[M] == char{}); gsl_Expects(detail::is_basic_literal_character_set(a)); } - constexpr basic_symbol_text(const fixed_u8string& u, const fixed_string& a) : unicode_(u), ascii_(a) + constexpr symbol_text(const fixed_u8string& u, const fixed_string& a) : unicode_(u), ascii_(a) { gsl_Expects(detail::is_basic_literal_character_set(a.data_)); } @@ -123,15 +122,14 @@ struct basic_symbol_text { } template - [[nodiscard]] constexpr friend basic_symbol_text operator+(const basic_symbol_text& lhs, - const basic_symbol_text& rhs) + [[nodiscard]] constexpr friend symbol_text operator+(const symbol_text& lhs, + const symbol_text& rhs) { - return basic_symbol_text(lhs.unicode() + rhs.unicode(), lhs.ascii() + rhs.ascii()); + return symbol_text(lhs.unicode() + rhs.unicode(), lhs.ascii() + rhs.ascii()); } template - [[nodiscard]] friend constexpr auto operator<=>(const basic_symbol_text& lhs, - const basic_symbol_text& rhs) noexcept + [[nodiscard]] friend constexpr auto operator<=>(const symbol_text& lhs, const symbol_text& rhs) noexcept { MP_UNITS_DIAGNOSTIC_PUSH MP_UNITS_DIAGNOSTIC_IGNORE_ZERO_AS_NULLPOINTER_CONSTANT @@ -141,25 +139,24 @@ struct basic_symbol_text { } template - [[nodiscard]] friend constexpr bool operator==(const basic_symbol_text& lhs, - const basic_symbol_text& rhs) noexcept + [[nodiscard]] friend constexpr bool operator==(const symbol_text& lhs, const symbol_text& rhs) noexcept { return lhs.unicode() == rhs.unicode() && lhs.ascii() == rhs.ascii(); } }; -basic_symbol_text(char) -> basic_symbol_text<1, 1>; +symbol_text(char) -> symbol_text<1, 1>; template -basic_symbol_text(const char (&)[N]) -> basic_symbol_text; +symbol_text(const char (&)[N]) -> symbol_text; template -basic_symbol_text(const fixed_string&) -> basic_symbol_text; +symbol_text(const fixed_string&) -> symbol_text; template -basic_symbol_text(const char8_t (&)[N], const char (&)[M]) -> basic_symbol_text; +symbol_text(const char8_t (&)[N], const char (&)[M]) -> symbol_text; template -basic_symbol_text(const fixed_u8string&, const fixed_string&) -> basic_symbol_text; +symbol_text(const fixed_u8string&, const fixed_string&) -> symbol_text; } // namespace mp_units diff --git a/src/core/include/mp-units/bits/text_tools.h b/src/core/include/mp-units/bits/text_tools.h index 5feeda8b..22445a66 100644 --- a/src/core/include/mp-units/bits/text_tools.h +++ b/src/core/include/mp-units/bits/text_tools.h @@ -56,9 +56,9 @@ inline constexpr basic_fixed_string superscript_number<8> = u8"\u2078"; template<> inline constexpr basic_fixed_string superscript_number<9> = u8"\u2079"; -inline constexpr basic_symbol_text superscript_minus(u8"\u207b", "-"); +inline constexpr symbol_text superscript_minus(u8"\u207b", "-"); -inline constexpr basic_symbol_text superscript_prefix(u8"", "^"); +inline constexpr symbol_text superscript_prefix(u8"", "^"); template [[nodiscard]] consteval auto superscript_helper() @@ -66,7 +66,7 @@ template if constexpr (Value < 0) return superscript_minus + superscript_helper<-Value>(); else if constexpr (Value < 10) - return basic_symbol_text(superscript_number, basic_fixed_string(static_cast('0' + Value))); + return symbol_text(superscript_number, basic_fixed_string(static_cast('0' + Value))); else return superscript_helper() + superscript_helper(); } @@ -81,9 +81,9 @@ template [[nodiscard]] consteval auto regular() { if constexpr (Value < 0) - return basic_symbol_text("-") + superscript_helper<-Value>(); + return symbol_text("-") + superscript_helper<-Value>(); else if constexpr (Value < 10) - return basic_symbol_text(static_cast('0' + Value)); + return symbol_text(static_cast('0' + Value)); else return regular() + regular(); } @@ -99,7 +99,7 @@ MP_UNITS_EXPORT enum class text_encoding : std::int8_t { namespace detail { template Out> -constexpr Out copy(const basic_symbol_text& txt, text_encoding encoding, Out out) +constexpr Out copy(const symbol_text& txt, text_encoding encoding, Out out) { if (encoding == text_encoding::unicode) { if constexpr (is_same_v) @@ -118,7 +118,7 @@ constexpr Out copy(const basic_symbol_text& txt, text_encoding encoding, O } template Out> -constexpr Out copy_symbol(const basic_symbol_text& txt, text_encoding encoding, bool negative_power, Out out) +constexpr Out copy_symbol(const symbol_text& txt, text_encoding encoding, bool negative_power, Out out) { out = copy(txt, encoding, out); if (negative_power) { @@ -135,12 +135,12 @@ constexpr Out copy_symbol_exponent(text_encoding encoding, bool negative_power, if constexpr (r.den != 1) { // add root part if (negative_power) { - constexpr auto txt = basic_symbol_text("^-(") + regular() + basic_symbol_text("/") + regular() + - basic_symbol_text(")"); + constexpr auto txt = + symbol_text("^-(") + regular() + symbol_text("/") + regular() + symbol_text(")"); return copy(txt, encoding, out); } else { constexpr auto txt = - basic_symbol_text("^(") + regular() + basic_symbol_text("/") + regular() + basic_symbol_text(")"); + symbol_text("^(") + regular() + symbol_text("/") + regular() + symbol_text(")"); return copy(txt, encoding, out); } } else if constexpr (r.num != 1) { diff --git a/src/core/include/mp-units/bits/unit_concepts.h b/src/core/include/mp-units/bits/unit_concepts.h index 02e954e1..29331c7a 100644 --- a/src/core/include/mp-units/bits/unit_concepts.h +++ b/src/core/include/mp-units/bits/unit_concepts.h @@ -49,12 +49,12 @@ concept Unit = detail::is_unit::value; template struct scaled_unit; -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template struct named_unit; namespace detail { -template +template void to_base_specialization_of_named_unit(const volatile named_unit*); template @@ -64,7 +64,7 @@ inline constexpr bool is_derived_from_specialization_of_named_unit = template inline constexpr bool is_specialization_of_named_unit = false; -template +template inline constexpr bool is_specialization_of_named_unit> = true; /** @@ -114,7 +114,7 @@ concept DerivedUnitExpr = Unit || detail::is_power_of_unit || detail::is_p template struct derived_unit; -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template requires(!Symbol.empty()) struct prefixed_unit; @@ -123,7 +123,7 @@ namespace detail { template void is_unit_impl(const scaled_unit*); -template +template void is_unit_impl(const named_unit*); template @@ -132,13 +132,13 @@ void is_unit_impl(const derived_unit*); template inline constexpr bool is_specialization_of_unit = false; -template +template inline constexpr bool is_specialization_of_unit> = true; template inline constexpr bool is_specialization_of_prefixed_unit = false; -template +template inline constexpr bool is_specialization_of_prefixed_unit> = true; template diff --git a/src/core/include/mp-units/dimension.h b/src/core/include/mp-units/dimension.h index 25f032df..43e5f3ce 100644 --- a/src/core/include/mp-units/dimension.h +++ b/src/core/include/mp-units/dimension.h @@ -68,7 +68,7 @@ namespace mp_units { * * @tparam Symbol an unique identifier of the base dimension used to provide dimensional analysis support */ -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template struct base_dimension { static constexpr auto symbol = Symbol; ///< Unique base dimension identifier }; diff --git a/src/core/include/mp-units/unit.h b/src/core/include/mp-units/unit.h index 6bcbd96a..9de85fb0 100644 --- a/src/core/include/mp-units/unit.h +++ b/src/core/include/mp-units/unit.h @@ -111,7 +111,7 @@ inline constexpr bool is_specialization_of_scaled_unit> = true * * @tparam Symbol a short text representation of the unit */ -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template struct named_unit; /** @@ -130,14 +130,14 @@ struct named_unit; * @tparam Symbol a short text representation of the unit * @tparam QuantitySpec a specification of a base quantity to be measured with this unit */ -template +template requires(!Symbol.empty()) && detail::BaseDimension> struct named_unit { static constexpr auto symbol = Symbol; ///< Unique base unit identifier static constexpr auto quantity_spec = QS; }; -template +template requires(!Symbol.empty()) && detail::BaseDimension> struct named_unit { static constexpr auto symbol = Symbol; ///< Unique base unit identifier @@ -155,7 +155,7 @@ struct named_unit { * * @tparam Symbol a short text representation of the unit */ -template +template requires(!Symbol.empty()) struct named_unit { static constexpr auto symbol = Symbol; ///< Unique base unit identifier @@ -169,13 +169,13 @@ struct named_unit { * @tparam Symbol a short text representation of the unit * @tparam Unit a unit for which we provide a special name */ -template +template requires(!Symbol.empty()) struct named_unit : std::remove_const_t { static constexpr auto symbol = Symbol; ///< Unique unit identifier }; -template +template requires(!Symbol.empty()) struct named_unit : std::remove_const_t { static constexpr auto symbol = Symbol; ///< Unique unit identifier @@ -191,14 +191,14 @@ struct named_unit : std::remove_const_t { * @tparam Unit a unit for which we provide a special name * @tparam QuantitySpec a specification of a quantity to be measured with this unit */ -template +template requires(!Symbol.empty()) && (QS.dimension == detail::get_associated_quantity(U).dimension) struct named_unit : std::remove_const_t { static constexpr auto symbol = Symbol; ///< Unique unit identifier static constexpr auto quantity_spec = QS; }; -template +template requires(!Symbol.empty()) && (QS.dimension == detail::get_associated_quantity(U).dimension) struct named_unit : std::remove_const_t { static constexpr auto symbol = Symbol; ///< Unique unit identifier @@ -228,7 +228,7 @@ struct named_unit : std::remove_const_t { * @tparam M scaling factor of the prefix * @tparam U a named unit to be prefixed */ -MP_UNITS_EXPORT template +MP_UNITS_EXPORT template requires(!Symbol.empty()) struct prefixed_unit : std::remove_const_t { static constexpr auto symbol = Symbol + U.symbol; @@ -330,13 +330,13 @@ canonical_unit(M, U) -> canonical_unit; #endif -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T t, const named_unit&); -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T t, const named_unit&); -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const named_unit&); template @@ -352,19 +352,19 @@ template return canonical_unit{M * base.mag, base.reference_unit}; } -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T t, const named_unit&) { return canonical_unit{mag<1>, t}; } -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T t, const named_unit&) { return canonical_unit{mag<1>, t}; } -template +template [[nodiscard]] consteval auto get_canonical_unit_impl(T, const named_unit&) { return get_canonical_unit_impl(U, U); @@ -491,7 +491,7 @@ namespace detail { [[nodiscard]] consteval bool have_same_canonical_reference_unit_impl(...) { return false; } -template +template [[nodiscard]] consteval bool have_same_canonical_reference_unit_impl(const named_unit&, const named_unit&) { @@ -618,7 +618,7 @@ template // common dimensionless units // clang-format off inline constexpr struct percent : named_unit<"%", mag * one> {} percent; -inline constexpr struct per_mille : named_unit * one> {} per_mille; +inline constexpr struct per_mille : named_unit * one> {} per_mille; inline constexpr struct parts_per_million : named_unit<"ppm", mag * one> {} parts_per_million; inline constexpr auto ppm = parts_per_million; // clang-format on diff --git a/src/systems/include/mp-units/systems/angular/units.h b/src/systems/include/mp-units/systems/angular/units.h index 28b95429..3f819eb2 100644 --- a/src/systems/include/mp-units/systems/angular/units.h +++ b/src/systems/include/mp-units/systems/angular/units.h @@ -40,8 +40,8 @@ QUANTITY_SPEC(solid_angle, pow<2>(angle)); inline constexpr struct radian : named_unit<"rad", kind_of> {} radian; inline constexpr struct revolution : named_unit<"rev", mag<2> * mag_pi * radian> {} revolution; -inline constexpr struct degree : named_unit * revolution> {} degree; -inline constexpr struct gradian : named_unit * revolution> {} gradian; +inline constexpr struct degree : named_unit * revolution> {} degree; +inline constexpr struct gradian : named_unit * revolution> {} gradian; inline constexpr struct steradian : named_unit<"sr", square(radian)> {} steradian; // clang-format on diff --git a/src/systems/include/mp-units/systems/iau/iau.h b/src/systems/include/mp-units/systems/iau/iau.h index ccb54ede..34d8c9d0 100644 --- a/src/systems/include/mp-units/systems/iau/iau.h +++ b/src/systems/include/mp-units/systems/iau/iau.h @@ -43,7 +43,7 @@ inline constexpr struct Julian_year : named_unit<"a", mag * // mass // https://en.wikipedia.org/wiki/Solar_mass // TODO What is the official mass of sun (every source in the Internet provides a different value) -inline constexpr struct solar_mass : named_unit * mag_power<10, 30> * si::kilogram> {} solar_mass; +inline constexpr struct solar_mass : named_unit * mag_power<10, 30> * si::kilogram> {} solar_mass; inline constexpr struct Jupiter_mass : named_unit<"M_JUP", mag * mag_power<10, 27> * si::kilogram> {} Jupiter_mass; inline constexpr struct Earth_mass : named_unit<"M_EARTH", mag * mag_power<10, 24> * si::kilogram> {} Earth_mass; @@ -60,7 +60,7 @@ inline constexpr struct light_year : named_unit<"ly", mag<9'460'730'472'580'800> inline constexpr struct parsec : named_unit<"pc", astronomical_unit / (mag * si::degree)> {} parsec; // https://en.wikipedia.org/wiki/Angstrom -inline constexpr struct angstrom : named_unit * si::metre> {} angstrom; +inline constexpr struct angstrom : named_unit * si::metre> {} angstrom; // selected constants // https://en.wikipedia.org/wiki/Astronomical_constant @@ -68,13 +68,13 @@ inline constexpr struct gaussian_gravitational_constant : named_unit<"k", mag * pow<3, 2>(astronomical_unit) / pow<1,2>(solar_mass) / day> {} gaussian_gravitational_constant; inline constexpr struct speed_of_light : - named_unit {} speed_of_light; + named_unit {} speed_of_light; inline constexpr struct constant_of_gravitation : named_unit<"G", mag * mag_power<10, -11> * cubic(si::metre) / si::kilogram / square(si::second)> {} constant_of_gravitation; inline constexpr struct hubble_constant : - named_unit * si::kilo / si::second / si::mega> {} hubble_constant; + named_unit * si::kilo / si::second / si::mega> {} hubble_constant; // clang-format on namespace unit_symbols { diff --git a/src/systems/include/mp-units/systems/isq/base_quantities.h b/src/systems/include/mp-units/systems/isq/base_quantities.h index 2cf41402..89bc15eb 100644 --- a/src/systems/include/mp-units/systems/isq/base_quantities.h +++ b/src/systems/include/mp-units/systems/isq/base_quantities.h @@ -39,7 +39,7 @@ inline constexpr struct dim_length : base_dimension<"L"> {} dim_length; inline constexpr struct dim_mass : base_dimension<"M"> {} dim_mass; inline constexpr struct dim_time : base_dimension<"T"> {} dim_time; inline constexpr struct dim_electric_current : base_dimension<"I"> {} dim_electric_current; -inline constexpr struct dim_thermodynamic_temperature : base_dimension {} dim_thermodynamic_temperature; +inline constexpr struct dim_thermodynamic_temperature : base_dimension {} dim_thermodynamic_temperature; inline constexpr struct dim_amount_of_substance : base_dimension<"N"> {} dim_amount_of_substance; inline constexpr struct dim_luminous_intensity : base_dimension<"J"> {} dim_luminous_intensity; // clang-format on diff --git a/src/systems/include/mp-units/systems/si/constants.h b/src/systems/include/mp-units/systems/si/constants.h index 565b2db3..012e2cf4 100644 --- a/src/systems/include/mp-units/systems/si/constants.h +++ b/src/systems/include/mp-units/systems/si/constants.h @@ -36,7 +36,7 @@ namespace si2019 { // clang-format off inline constexpr struct hyperfine_structure_transition_frequency_of_cs : - named_unit * hertz> {} hyperfine_structure_transition_frequency_of_cs; + named_unit * hertz> {} hyperfine_structure_transition_frequency_of_cs; inline constexpr struct speed_of_light_in_vacuum : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; inline constexpr struct planck_constant : @@ -55,9 +55,9 @@ inline constexpr struct luminous_efficacy : // clang-format off inline constexpr struct standard_gravity : - named_unit * metre / square(second)> {} standard_gravity; + named_unit * metre / square(second)> {} standard_gravity; inline constexpr struct magnetic_constant : - named_unit * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant; + named_unit * mag_pi * mag_power<10, -7> * henry / metre> {} magnetic_constant; // clang-format on } // namespace mp_units::si diff --git a/src/systems/include/mp-units/systems/si/prefixes.h b/src/systems/include/mp-units/systems/si/prefixes.h index 22ef8811..69077888 100644 --- a/src/systems/include/mp-units/systems/si/prefixes.h +++ b/src/systems/include/mp-units/systems/si/prefixes.h @@ -39,7 +39,7 @@ template struct atto_ : prefixed_unit<"a", mag_power<10, -18> template struct femto_ : prefixed_unit<"f", mag_power<10, -15>, U{}> {}; template struct pico_ : prefixed_unit<"p", mag_power<10, -12>, U{}> {}; template struct nano_ : prefixed_unit<"n", mag_power<10, -9>, U{}> {}; -template struct micro_ : prefixed_unit, U{}> {}; +template struct micro_ : prefixed_unit, U{}> {}; template struct milli_ : prefixed_unit<"m", mag_power<10, -3>, U{}> {}; template struct centi_ : prefixed_unit<"c", mag_power<10, -2>, U{}> {}; template struct deci_ : prefixed_unit<"d", mag_power<10, -1>, U{}> {}; diff --git a/src/systems/include/mp-units/systems/si/units.h b/src/systems/include/mp-units/systems/si/units.h index 05d2a8b4..7634aae3 100644 --- a/src/systems/include/mp-units/systems/si/units.h +++ b/src/systems/include/mp-units/systems/si/units.h @@ -75,7 +75,7 @@ inline constexpr struct watt : named_unit<"W", joule / second> {} watt; inline constexpr struct coulomb : named_unit<"C", ampere * second> {} coulomb; inline constexpr struct volt : named_unit<"V", watt / ampere> {} volt; inline constexpr struct farad : named_unit<"F", coulomb / volt> {} farad; -inline constexpr struct ohm : named_unit {} ohm; +inline constexpr struct ohm : named_unit {} ohm; inline constexpr struct siemens : named_unit<"S", one / ohm> {} siemens; inline constexpr struct weber : named_unit<"Wb", volt * second> {} weber; inline constexpr struct tesla : named_unit<"T", weber / square(metre)> {} tesla; @@ -83,7 +83,7 @@ inline constexpr struct henry : named_unit<"H", weber / ampere> {} henry; inline constexpr struct ice_point : relative_point_origin}> {} ice_point; inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius; -inline constexpr struct degree_Celsius : named_unit {} degree_Celsius; +inline constexpr struct degree_Celsius : named_unit {} degree_Celsius; inline constexpr struct lumen : named_unit<"lm", candela * steradian> {} lumen; inline constexpr struct lux : named_unit<"lx", lumen / square(metre)> {} lux; @@ -103,9 +103,9 @@ inline constexpr struct minute : named_unit<"min", mag<60> * si::second> {} minu inline constexpr struct hour : named_unit<"h", mag<60> * minute> {} hour; inline constexpr struct day : named_unit<"d", mag<24> * hour> {} day; inline constexpr struct astronomical_unit : named_unit<"au", mag<149'597'870'700> * si::metre> {} astronomical_unit; -inline constexpr struct degree : named_unit * si::radian> {} degree; -inline constexpr struct arcminute : named_unit * degree> {} arcminute; -inline constexpr struct arcsecond : named_unit * arcminute> {} arcsecond; +inline constexpr struct degree : named_unit * si::radian> {} degree; +inline constexpr struct arcminute : named_unit * degree> {} arcminute; +inline constexpr struct arcsecond : named_unit * arcminute> {} arcsecond; inline constexpr struct are : named_unit<"a", square(si::deca)> {} are; #if MP_UNITS_COMP_MSVC inline constexpr struct hectare : si::hecto_ {} hectare; diff --git a/src/systems/include/mp-units/systems/usc/usc.h b/src/systems/include/mp-units/systems/usc/usc.h index e6fd2a2f..cac1e08a 100644 --- a/src/systems/include/mp-units/systems/usc/usc.h +++ b/src/systems/include/mp-units/systems/usc/usc.h @@ -116,7 +116,7 @@ inline constexpr struct inch_of_mercury : named_unit<"inHg", mag * si::degree_Celsius)> {} zeroth_degree_Fahrenheit; -inline constexpr struct degree_Fahrenheit : named_unit * si::degree_Celsius, zeroth_degree_Fahrenheit> {} degree_Fahrenheit; +inline constexpr struct degree_Fahrenheit : named_unit * si::degree_Celsius, zeroth_degree_Fahrenheit> {} degree_Fahrenheit; // clang-format on diff --git a/test/static/symbol_text_test.cpp b/test/static/symbol_text_test.cpp index ea74dfec..f11d0789 100644 --- a/test/static/symbol_text_test.cpp +++ b/test/static/symbol_text_test.cpp @@ -26,10 +26,10 @@ using namespace mp_units; namespace { -constexpr basic_symbol_text sym1('b'); +constexpr symbol_text sym1('b'); static_assert(sym1 == 'b'); static_assert(sym1 != 'a'); -static_assert(sym1 != basic_symbol_text("ab")); +static_assert(sym1 != symbol_text("ab")); static_assert(sym1 < 'c'); static_assert(sym1 > 'a'); static_assert(sym1 <= 'b'); @@ -39,45 +39,45 @@ static_assert(sym1 >= 'a'); static_assert(sym1.unicode() == u8"b"); static_assert(sym1.ascii() == "b"); -constexpr basic_symbol_text sym3("ab"); +constexpr symbol_text sym3("ab"); static_assert(sym3.unicode() == u8"ab"); static_assert(sym3.ascii() == "ab"); constexpr basic_fixed_string txt1("bc"); -constexpr basic_symbol_text sym4(txt1); +constexpr symbol_text sym4(txt1); static_assert(sym4.unicode() == u8"bc"); static_assert(sym4.ascii() == "bc"); -constexpr basic_symbol_text sym5(u8"bc", "de"); +constexpr symbol_text sym5(u8"bc", "de"); static_assert(sym5.unicode() == u8"bc"); static_assert(sym5.ascii() == "de"); constexpr basic_fixed_string txt2("de"); -constexpr basic_symbol_text sym6(sym4.unicode(), txt2); +constexpr symbol_text sym6(sym4.unicode(), txt2); static_assert(sym6.unicode() == u8"bc"); static_assert(sym6.ascii() == "de"); -static_assert(sym6 == basic_symbol_text(u8"bc", "de")); -static_assert(sym6 != basic_symbol_text(u8"fg", "hi")); -static_assert(sym6 != basic_symbol_text(u8"bcd", "ef")); +static_assert(sym6 == symbol_text(u8"bc", "de")); +static_assert(sym6 != symbol_text(u8"fg", "hi")); +static_assert(sym6 != symbol_text(u8"bcd", "ef")); -static_assert(sym6 < basic_symbol_text("c")); -static_assert(sym6 > basic_symbol_text("a")); -static_assert(sym6 <= basic_symbol_text("c")); -static_assert(sym6 <= basic_symbol_text("bcd")); -static_assert(sym6 >= basic_symbol_text("a")); -static_assert(sym6 >= basic_symbol_text("bc")); +static_assert(sym6 < symbol_text("c")); +static_assert(sym6 > symbol_text("a")); +static_assert(sym6 <= symbol_text("c")); +static_assert(sym6 <= symbol_text("bcd")); +static_assert(sym6 >= symbol_text("a")); +static_assert(sym6 >= symbol_text("bc")); -static_assert(basic_symbol_text("a") + sym4 == basic_symbol_text("abc")); -static_assert(sym4 + basic_symbol_text("f") == basic_symbol_text("bcf")); +static_assert(symbol_text("a") + sym4 == symbol_text("abc")); +static_assert(sym4 + symbol_text("f") == symbol_text("bcf")); -static_assert(basic_symbol_text(u8"a", "f") + sym6 == basic_symbol_text(u8"abc", "fde")); -static_assert(sym6 + basic_symbol_text(u8"a", "f") == basic_symbol_text(u8"bca", "def")); +static_assert(symbol_text(u8"a", "f") + sym6 == symbol_text(u8"abc", "fde")); +static_assert(sym6 + symbol_text(u8"a", "f") == symbol_text(u8"bca", "def")); -static_assert(basic_symbol_text('a') + sym6 == basic_symbol_text(u8"abc", "ade")); -static_assert(sym6 + basic_symbol_text('f') == basic_symbol_text(u8"bcf", "def")); +static_assert(symbol_text('a') + sym6 == symbol_text(u8"abc", "ade")); +static_assert(sym6 + symbol_text('f') == symbol_text(u8"bcf", "def")); -static_assert(basic_symbol_text("a") + sym6 == basic_symbol_text(u8"abc", "ade")); -static_assert(sym6 + basic_symbol_text("f") == basic_symbol_text(u8"bcf", "def")); +static_assert(symbol_text("a") + sym6 == symbol_text(u8"abc", "ade")); +static_assert(sym6 + symbol_text("f") == symbol_text(u8"bcf", "def")); } // namespace diff --git a/test/static/unit_test.cpp b/test/static/unit_test.cpp index eff9b77f..5fdbda57 100644 --- a/test/static/unit_test.cpp +++ b/test/static/unit_test.cpp @@ -40,7 +40,7 @@ using percent_ = struct percent; inline constexpr struct dim_length_ : base_dimension<"L"> {} dim_length; inline constexpr struct dim_mass_ : base_dimension<"M"> {} dim_mass; inline constexpr struct dim_time_ : base_dimension<"T"> {} dim_time; -inline constexpr struct dim_thermodynamic_temperature_ : base_dimension {} dim_thermodynamic_temperature; +inline constexpr struct dim_thermodynamic_temperature_ : base_dimension {} dim_thermodynamic_temperature; // quantities specification QUANTITY_SPEC_(length, dim_length); @@ -67,11 +67,11 @@ inline constexpr struct newton_ : named_unit<"N", kilogram * metre / square(seco inline constexpr struct pascal_ : named_unit<"Pa", newton / square(metre)> {} pascal; inline constexpr struct joule_ : named_unit<"J", newton * metre> {} joule; inline constexpr struct watt_ : named_unit<"W", joule / second> {} watt; -inline constexpr struct degree_Celsius_ : named_unit {} degree_Celsius; +inline constexpr struct degree_Celsius_ : named_unit {} degree_Celsius; inline constexpr struct minute_ : named_unit<"min", mag<60> * second> {} minute; inline constexpr struct hour_ : named_unit<"h", mag<60> * minute> {} hour; -inline constexpr struct degree_ : named_unit * radian> {} degree; +inline constexpr struct degree_ : named_unit * radian> {} degree; inline constexpr struct yard_ : named_unit<"yd", mag * metre> {} yard; inline constexpr struct mile_ : named_unit<"mi", mag<1760> * yard> {} mile; @@ -80,7 +80,7 @@ inline constexpr struct kilometre_ : decltype(si::kilo) {} kilometre; inline constexpr struct kilojoule_ : decltype(si::kilo) {} kilojoule; // physical constant units -inline constexpr struct standard_gravity_ : named_unit * metre / square(second)> {} standard_gravity; +inline constexpr struct standard_gravity_ : named_unit * metre / square(second)> {} standard_gravity; inline constexpr struct speed_of_light_in_vacuum_ : named_unit<"c", mag<299'792'458> * metre / second> {} speed_of_light_in_vacuum; // clang-format on @@ -190,7 +190,7 @@ static_assert(convertible(standard_gravity, standard_gravity)); static_assert(convertible(standard_gravity, metre / square(second))); static_assert(standard_gravity == standard_gravity); static_assert(standard_gravity != metre / square(second)); // magnitude is different -static_assert(standard_gravity.symbol == basic_symbol_text{u8"g₀", "g_0"}); +static_assert(standard_gravity.symbol == symbol_text{u8"g₀", "g_0"}); // prefixed_unit static_assert(is_of_type); @@ -225,7 +225,7 @@ static_assert(si::atto.symbol == "am"); static_assert(si::femto.symbol == "fm"); static_assert(si::pico.symbol == "pm"); static_assert(si::nano.symbol == "nm"); -static_assert(si::micro.symbol == basic_symbol_text{u8"µm", "um"}); +static_assert(si::micro.symbol == symbol_text{u8"µm", "um"}); static_assert(si::milli.symbol == "mm"); static_assert(si::centi.symbol == "cm"); static_assert(si::deci.symbol == "dm");