refactor: degree Celsius and Fahrenheit symbols text now use Unicode codepoints

This commit is contained in:
Mateusz Pusz
2024-07-02 11:43:53 +01:00
parent e41078b889
commit 1365d62293
6 changed files with 12 additions and 12 deletions

View File

@@ -316,7 +316,7 @@ marked `final` (:boom: **breaking change** :boom:).
inline constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point; inline constexpr struct ice_point final : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
inline constexpr auto zeroth_degree_Celsius = ice_point; inline constexpr auto zeroth_degree_Celsius = ice_point;
inline constexpr struct degree_Celsius final : named_unit<symbol_text{u8"°C", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; inline constexpr struct degree_Celsius final : named_unit<symbol_text{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
``` ```
=== "Before" === "Before"
@@ -331,7 +331,7 @@ marked `final` (:boom: **breaking change** :boom:).
inline constexpr struct ice_point : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point; inline constexpr struct ice_point : relative_point_origin<quantity_point{273'150 * milli<kelvin>}> {} ice_point;
inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius; inline constexpr struct zeroth_degree_Celsius : decltype(ice_point) {} zeroth_degree_Celsius;
inline constexpr struct degree_Celsius : named_unit<symbol_text{u8"°C", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; inline constexpr struct degree_Celsius : named_unit<symbol_text{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
``` ```
Please also note, that the `absolute_point_origin` does not use CRTP idiom anymore (:boom: **breaking change** :boom:). Please also note, that the `absolute_point_origin` does not use CRTP idiom anymore (:boom: **breaking change** :boom:).

View File

@@ -292,7 +292,7 @@ This introduces an additional type-safety.
The above outputs: The above outputs:
```text ```text
Temperature: 20 °C (68 °F) Temperature: 20 (68 )
``` ```
!!! info !!! info

View File

@@ -445,14 +445,14 @@ namespace si {
inline constexpr struct kelvin final : inline constexpr struct kelvin final :
named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin; named_unit<"K", kind_of<isq::thermodynamic_temperature>, zeroth_kelvin> {} kelvin;
inline constexpr struct degree_Celsius final : inline constexpr struct degree_Celsius final :
named_unit<{u8"°C", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius; named_unit<{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {} degree_Celsius;
} }
namespace usc { namespace usc {
inline constexpr struct degree_Fahrenheit final : inline constexpr struct degree_Fahrenheit final :
named_unit<{u8"°F", "`F"}, mag_ratio<5, 9> * si::degree_Celsius, named_unit<{u8"", "`F"}, mag_ratio<5, 9> * si::degree_Celsius,
zeroth_degree_Fahrenheit> {} degree_Fahrenheit; zeroth_degree_Fahrenheit> {} degree_Fahrenheit;
} }
@@ -532,13 +532,13 @@ print_temp("Highest", room_high);
The above prints: The above prints:
```text ```text
Room reference temperature: 21 °C (69.8 °F, 294.15 K) Room reference temperature: 21 (69.8 , 294.15 K)
| Temperature delta | Room reference | Ice point | Absolute zero | | Temperature delta | Room reference | Ice point | Absolute zero |
|====================|====================|====================|====================| |====================|====================|====================|====================|
| Lowest | -3 °C | 18 °C | 291.15 °C | | Lowest | -3 | 18 | 291.15 |
| Default | 0 °C | 21 °C | 294.15 °C | | Default | 0 | 21 | 294.15 |
| Highest | 3 °C | 24 °C | 297.15 °C | | Highest | 3 | 24 | 297.15 |
``` ```

View File

@@ -109,7 +109,7 @@ inline constexpr bool is_specialization_of_scaled_unit<scaled_unit<M, U>> = true
* inline constexpr struct metre final : named_unit<"m", kind_of<length> {} metre; * inline constexpr struct metre final : named_unit<"m", kind_of<length> {} metre;
* inline constexpr struct hertz final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz; * inline constexpr struct hertz final : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
* inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton; * inline constexpr struct newton final : named_unit<"N", kilogram * metre / square(second)> {} newton;
* inline constexpr struct degree_Celsius final : named_unit<{u8"°C", "`C"}, kelvin, zeroth_degree_Celsius> {} * inline constexpr struct degree_Celsius final : named_unit<{u8"", "`C"}, kelvin, zeroth_degree_Celsius> {}
* degree_Celsius; inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute; * degree_Celsius; inline constexpr struct minute final : named_unit<"min", mag<60> * second> {} minute;
* @endcode * @endcode
* *

View File

@@ -39,7 +39,7 @@ using enum unit_symbol_separator;
static_assert(unit_symbol(metre) == "m"); static_assert(unit_symbol(metre) == "m");
static_assert(unit_symbol(second) == "s"); static_assert(unit_symbol(second) == "s");
static_assert(unit_symbol(joule) == "J"); static_assert(unit_symbol(joule) == "J");
static_assert(unit_symbol(degree_Celsius) == "\u00B0C"); static_assert(unit_symbol(degree_Celsius) == "\u2103");
static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(degree_Celsius) == "`C"); static_assert(unit_symbol<unit_symbol_formatting{.encoding = ascii}>(degree_Celsius) == "`C");
static_assert(unit_symbol(kilogram) == "kg"); static_assert(unit_symbol(kilogram) == "kg");
static_assert(unit_symbol(hour) == "h"); static_assert(unit_symbol(hour) == "h");

View File

@@ -66,7 +66,7 @@ inline constexpr struct newton_ final : named_unit<"N", kilogram * metre / squar
inline constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal; inline constexpr struct pascal_ final : named_unit<"Pa", newton / square(metre)> {} pascal;
inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule; inline constexpr struct joule_ final : named_unit<"J", newton * metre> {} joule;
inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt; inline constexpr struct watt_ final : named_unit<"W", joule / second> {} watt;
inline constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"°C", "`C"}, kelvin> {} degree_Celsius; inline constexpr struct degree_Celsius_ final : named_unit<symbol_text{u8"", "`C"}, kelvin> {} degree_Celsius;
inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute; inline constexpr struct minute_ final : named_unit<"min", mag<60> * second> {} minute;
inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour; inline constexpr struct hour_ final : named_unit<"h", mag<60> * minute> {} hour;