From 411f7a0bb7107f47badbf5f36c0be4caafa967e1 Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Wed, 9 Nov 2022 22:50:19 -1000 Subject: [PATCH] refactor: `magnitude_text()` moved to the magnitude header file --- src/core/include/units/unit.h | 40 +---------------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) diff --git a/src/core/include/units/unit.h b/src/core/include/units/unit.h index a2fe3d19..d386dc96 100644 --- a/src/core/include/units/unit.h +++ b/src/core/include/units/unit.h @@ -131,7 +131,7 @@ inline constexpr bool is_specialization_of_scaled_unit> = true * inline constexpr struct metre : named_unit<"m", length> {} metre; * inline constexpr struct hertz : named_unit<"Hz", 1 / second> {} hertz; * inline constexpr struct newton : named_unit<"N", kilogram * metre / square> {} newton; - * 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; * @endcode * @@ -619,44 +619,6 @@ constexpr Out copy(const basic_symbol_text& txt, text_encodi } } -inline constexpr basic_symbol_text base_multiplier("\u00D7 10", "x 10"); - -template -constexpr auto magnitude_text() -{ - constexpr auto exp10 = extract_power_of_10(M); - - constexpr Magnitude auto base = M / mag_power<10, exp10>; - constexpr Magnitude auto num = numerator(base); - constexpr Magnitude auto den = denominator(base); - static_assert(base == num / den, "Printing rational powers, or irrational bases, not yet supported"); - - constexpr auto num_value = get_value(num); - constexpr auto den_value = get_value(den); - - 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_fixed_string("[") + regular(); - if constexpr (den_value == 1) { - if constexpr (exp10 == 0) { - return txt + basic_fixed_string("]"); - } else { - return txt + " " + base_multiplier + superscript() + basic_fixed_string("]"); - } - } else { - if constexpr (exp10 == 0) { - return txt + basic_fixed_string("/") + regular() + basic_fixed_string("]"); - } else { - return txt + basic_fixed_string("/") + regular() + " " + base_multiplier + superscript() + - basic_fixed_string("]"); - } - } - } else { - return basic_fixed_string(""); - } -} - template Out> constexpr Out print_separator(Out out, unit_symbol_formatting fmt) {