refactor: 💥 text_encoding renamed to character_set

This commit is contained in:
Mateusz Pusz
2024-11-19 14:44:59 +01:00
parent dcf05687cf
commit 8ae21ffcc9
10 changed files with 128 additions and 115 deletions

View File

@ -454,15 +454,15 @@ as text and, thus, are aligned to the left by default.
```ebnf ```ebnf
dimension-format-spec = [fill-and-align], [width], [dimension-spec]; dimension-format-spec = [fill-and-align], [width], [dimension-spec];
dimension-spec = [text-encoding]; dimension-spec = [character-set];
text-encoding = 'U' | 'P'; character-set = 'U' | 'P';
``` ```
In the above grammar: In the above grammar:
- `fill-and-align` and `width` tokens are defined in the [format.string.std](https://wg21.link/format.string.std) - `fill-and-align` and `width` tokens are defined in the [format.string.std](https://wg21.link/format.string.std)
chapter of the C++ standard specification, chapter of the C++ standard specification,
- `text-encoding` token specifies the symbol text encoding: - `character-set` token specifies the symbol text encoding:
- `U` (default) uses the **UTF-8** symbols defined by [@ISO80000] (e.g., `LT⁻²`), - `U` (default) uses the **UTF-8** symbols defined by [@ISO80000] (e.g., `LT⁻²`),
- `P` forces non-standard **portable** output (e.g., `LT^-2`). - `P` forces non-standard **portable** output (e.g., `LT^-2`).
@ -471,7 +471,7 @@ Dimension symbols of some quantities are specified to use Unicode signs by the
dimension). The library follows this by default. From the engineering point of view, sometimes dimension). The library follows this by default. From the engineering point of view, sometimes
Unicode text might not be the best solution, as terminals of many (especially embedded) devices Unicode text might not be the best solution, as terminals of many (especially embedded) devices
can output only letters from the basic literal character set. In such a case, the dimension can output only letters from the basic literal character set. In such a case, the dimension
symbol can be forced to be printed using such characters thanks to `text-encoding` token: symbol can be forced to be printed using such characters thanks to `character-set` token:
```cpp ```cpp
std::println("{}", isq::dim_thermodynamic_temperature); // Θ std::println("{}", isq::dim_thermodynamic_temperature); // Θ
@ -484,12 +484,12 @@ std::println("{:P}", isq::power.dimension); // L^2MT^-3
```ebnf ```ebnf
unit-format-spec = [fill-and-align], [width], [unit-spec]; unit-format-spec = [fill-and-align], [width], [unit-spec];
unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L] unit-spec = [character-set], [unit-symbol-solidus], [unit-symbol-separator], [L]
| [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L] | [character-set], [unit-symbol-separator], [unit-symbol-solidus], [L]
| [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L] | [unit-symbol-solidus], [character-set], [unit-symbol-separator], [L]
| [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L] | [unit-symbol-solidus], [unit-symbol-separator], [character-set], [L]
| [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L] | [unit-symbol-separator], [character-set], [unit-symbol-solidus], [L]
| [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L]; | [unit-symbol-separator], [unit-symbol-solidus], [character-set], [L];
unit-symbol-solidus = '1' | 'a' | 'n'; unit-symbol-solidus = '1' | 'a' | 'n';
unit-symbol-separator = 's' | 'd'; unit-symbol-separator = 's' | 'd';
``` ```
@ -521,7 +521,7 @@ Unit symbols of some quantities are specified to use Unicode signs by the [SI](.
engineering point of view, Unicode text might not be the best solution sometimes, as terminals engineering point of view, Unicode text might not be the best solution sometimes, as terminals
of many (especially embedded) devices can output only letters from the basic literal character set. of many (especially embedded) devices can output only letters from the basic literal character set.
In such a case, the unit symbol can be forced to be printed using such characters thanks to In such a case, the unit symbol can be forced to be printed using such characters thanks to
`text-encoding` token: `character-set` token:
```cpp ```cpp
std::println("{}", si::ohm); // Ω std::println("{}", si::ohm); // Ω

View File

@ -96,9 +96,9 @@ template<std::intmax_t Value>
} }
template<typename CharT, std::size_t N, std::size_t M, std::output_iterator<CharT> Out> template<typename CharT, std::size_t N, std::size_t M, std::output_iterator<CharT> Out>
constexpr Out copy(const symbol_text<N, M>& txt, text_encoding encoding, Out out) constexpr Out copy(const symbol_text<N, M>& txt, character_set char_set, Out out)
{ {
if (encoding == text_encoding::utf8) { if (char_set == character_set::utf8) {
if constexpr (is_same_v<CharT, char8_t>) if constexpr (is_same_v<CharT, char8_t>)
return ::mp_units::detail::copy(txt.utf8().begin(), txt.utf8().end(), out); return ::mp_units::detail::copy(txt.utf8().begin(), txt.utf8().end(), out);
else if constexpr (is_same_v<CharT, char>) { else if constexpr (is_same_v<CharT, char>) {
@ -115,18 +115,18 @@ constexpr Out copy(const symbol_text<N, M>& txt, text_encoding encoding, Out out
} }
template<typename CharT, std::size_t N, std::size_t M, std::output_iterator<CharT> Out> template<typename CharT, std::size_t N, std::size_t M, std::output_iterator<CharT> Out>
constexpr Out copy_symbol(const symbol_text<N, M>& txt, text_encoding encoding, bool negative_power, Out out) constexpr Out copy_symbol(const symbol_text<N, M>& txt, character_set char_set, bool negative_power, Out out)
{ {
out = copy<CharT>(txt, encoding, out); out = copy<CharT>(txt, char_set, out);
if (negative_power) { if (negative_power) {
constexpr auto exp = superscript<-1>(); constexpr auto exp = superscript<-1>();
out = copy<CharT>(exp, encoding, out); out = copy<CharT>(exp, char_set, out);
} }
return out; return out;
} }
template<typename CharT, int Num, int... Den, std::output_iterator<CharT> Out> template<typename CharT, int Num, int... Den, std::output_iterator<CharT> Out>
constexpr Out copy_symbol_exponent(text_encoding encoding, bool negative_power, Out out) constexpr Out copy_symbol_exponent(character_set char_set, bool negative_power, Out out)
{ {
constexpr ratio r{Num, Den...}; constexpr ratio r{Num, Den...};
if constexpr (r.den != 1) { if constexpr (r.den != 1) {
@ -134,18 +134,18 @@ constexpr Out copy_symbol_exponent(text_encoding encoding, bool negative_power,
if (negative_power) { if (negative_power) {
constexpr auto txt = constexpr auto txt =
symbol_text("^-(") + regular<r.num>() + symbol_text("/") + regular<r.den>() + symbol_text(")"); symbol_text("^-(") + regular<r.num>() + symbol_text("/") + regular<r.den>() + symbol_text(")");
return copy<CharT>(txt, encoding, out); return copy<CharT>(txt, char_set, out);
} }
constexpr auto txt = symbol_text("^(") + regular<r.num>() + symbol_text("/") + regular<r.den>() + symbol_text(")"); constexpr auto txt = symbol_text("^(") + regular<r.num>() + symbol_text("/") + regular<r.den>() + symbol_text(")");
return copy<CharT>(txt, encoding, out); return copy<CharT>(txt, char_set, out);
} else if constexpr (r.num != 1) { } else if constexpr (r.num != 1) {
// add exponent part // add exponent part
if (negative_power) { if (negative_power) {
constexpr auto txt = superscript<-r.num>(); constexpr auto txt = superscript<-r.num>();
return copy<CharT>(txt, encoding, out); return copy<CharT>(txt, char_set, out);
} }
constexpr auto txt = superscript<r.num>(); constexpr auto txt = superscript<r.num>();
return copy<CharT>(txt, encoding, out); return copy<CharT>(txt, char_set, out);
} else { } else {
return out; return out;
} }

View File

@ -111,8 +111,8 @@ MP_UNITS_EXPORT_END
// Grammar // Grammar
// //
// dimension-format-spec = [fill-and-align], [width], [dimension-spec]; // dimension-format-spec = [fill-and-align], [width], [dimension-spec];
// dimension-spec = [text-encoding]; // dimension-spec = [character-set];
// text-encoding = 'U' | 'P'; // character-set = 'U' | 'P';
// //
template<mp_units::Dimension D, typename Char> template<mp_units::Dimension D, typename Char>
class MP_UNITS_STD_FMT::formatter<D, Char> { class MP_UNITS_STD_FMT::formatter<D, Char> {
@ -135,7 +135,7 @@ class MP_UNITS_STD_FMT::formatter<D, Char> {
if (it = mp_units::detail::at_most_one_of(begin, end, "UAP"); it != end) if (it = mp_units::detail::at_most_one_of(begin, end, "UAP"); it != end)
// TODO 'A' stands for an old and deprecated ASCII encoding // TODO 'A' stands for an old and deprecated ASCII encoding
specs_.encoding = (*it == 'U') ? mp_units::text_encoding::utf8 : mp_units::text_encoding::portable; specs_.char_set = (*it == 'U') ? mp_units::character_set::utf8 : mp_units::character_set::portable;
return end; return end;
} }
@ -177,12 +177,12 @@ public:
// Grammar // Grammar
// //
// unit-format-spec = [fill-and-align], [width], [unit-spec]; // unit-format-spec = [fill-and-align], [width], [unit-spec];
// unit-spec = [text-encoding], [unit-symbol-solidus], [unit-symbol-separator], [L] // unit-spec = [character-set], [unit-symbol-solidus], [unit-symbol-separator], [L]
// | [text-encoding], [unit-symbol-separator], [unit-symbol-solidus], [L] // | [character-set], [unit-symbol-separator], [unit-symbol-solidus], [L]
// | [unit-symbol-solidus], [text-encoding], [unit-symbol-separator], [L] // | [unit-symbol-solidus], [character-set], [unit-symbol-separator], [L]
// | [unit-symbol-solidus], [unit-symbol-separator], [text-encoding], [L] // | [unit-symbol-solidus], [unit-symbol-separator], [character-set], [L]
// | [unit-symbol-separator], [text-encoding], [unit-symbol-solidus], [L] // | [unit-symbol-separator], [character-set], [unit-symbol-solidus], [L]
// | [unit-symbol-separator], [unit-symbol-solidus], [text-encoding], [L]; // | [unit-symbol-separator], [unit-symbol-solidus], [character-set], [L];
// unit-symbol-solidus = '1' | 'a' | 'n'; // unit-symbol-solidus = '1' | 'a' | 'n';
// unit-symbol-separator = 's' | 'd'; // unit-symbol-separator = 's' | 'd';
// //
@ -208,7 +208,7 @@ class MP_UNITS_STD_FMT::formatter<U, Char> {
if (it = mp_units::detail::at_most_one_of(begin, end, "UAP"); it != end) if (it = mp_units::detail::at_most_one_of(begin, end, "UAP"); it != end)
// TODO 'A' stands for an old and deprecated ASCII encoding // TODO 'A' stands for an old and deprecated ASCII encoding
specs_.encoding = (*it == 'U') ? mp_units::text_encoding::utf8 : mp_units::text_encoding::portable; specs_.char_set = (*it == 'U') ? mp_units::character_set::utf8 : mp_units::character_set::portable;
if (it = mp_units::detail::at_most_one_of(begin, end, "1an"); it != end) { if (it = mp_units::detail::at_most_one_of(begin, end, "1an"); it != end) {
switch (*it) { switch (*it) {
case '1': case '1':
@ -223,7 +223,7 @@ class MP_UNITS_STD_FMT::formatter<U, Char> {
} }
} }
if (it = mp_units::detail::at_most_one_of(begin, end, "sd"); it != end) { if (it = mp_units::detail::at_most_one_of(begin, end, "sd"); it != end) {
if (*it == 'd' && specs_.encoding == mp_units::text_encoding::portable) if (*it == 'd' && specs_.char_set == mp_units::character_set::portable)
throw MP_UNITS_STD_FMT::format_error("half_high_dot unit separator allowed only for UTF-8 encoding"); throw MP_UNITS_STD_FMT::format_error("half_high_dot unit separator allowed only for UTF-8 encoding");
specs_.separator = specs_.separator =
(*it == 's') ? mp_units::unit_symbol_separator::space : mp_units::unit_symbol_separator::half_high_dot; (*it == 's') ? mp_units::unit_symbol_separator::space : mp_units::unit_symbol_separator::half_high_dot;

View File

@ -220,9 +220,13 @@ template<std::intmax_t Num, std::intmax_t Den = 1, Dimension D>
[[nodiscard]] consteval Dimension auto cbrt(Dimension auto d) { return pow<1, 3>(d); } [[nodiscard]] consteval Dimension auto cbrt(Dimension auto d) { return pow<1, 3>(d); }
MP_UNITS_DIAGNOSTIC_PUSH
MP_UNITS_DIAGNOSTIC_IGNORE_DEPRECATED
struct dimension_symbol_formatting { struct dimension_symbol_formatting {
text_encoding encoding = text_encoding::default_encoding; [[deprecated("Use `char_set` instead")]] character_set encoding = character_set::default_character_set;
character_set char_set = encoding;
}; };
MP_UNITS_DIAGNOSTIC_POP
MP_UNITS_EXPORT_END MP_UNITS_EXPORT_END
@ -232,7 +236,7 @@ template<typename CharT, std::output_iterator<CharT> Out, Dimension D>
requires requires { D::_symbol_; } requires requires { D::_symbol_; }
constexpr Out dimension_symbol_impl(Out out, D, const dimension_symbol_formatting& fmt, bool negative_power) constexpr Out dimension_symbol_impl(Out out, D, const dimension_symbol_formatting& fmt, bool negative_power)
{ {
return copy_symbol<CharT>(D::_symbol_, fmt.encoding, negative_power, out); return copy_symbol<CharT>(D::_symbol_, fmt.char_set, negative_power, out);
} }
template<typename CharT, std::output_iterator<CharT> Out, typename F, int Num, int... Den> template<typename CharT, std::output_iterator<CharT> Out, typename F, int Num, int... Den>
@ -240,7 +244,7 @@ constexpr auto dimension_symbol_impl(Out out, const power<F, Num, Den...>&, cons
bool negative_power) bool negative_power)
{ {
out = dimension_symbol_impl<CharT>(out, F{}, fmt, false); // negative power component will be added below if needed out = dimension_symbol_impl<CharT>(out, F{}, fmt, false); // negative power component will be added below if needed
return copy_symbol_exponent<CharT, Num, Den...>(fmt.encoding, negative_power, out); return copy_symbol_exponent<CharT, Num, Den...>(fmt.char_set, negative_power, out);
} }
template<typename CharT, std::output_iterator<CharT> Out, typename... Ms> template<typename CharT, std::output_iterator<CharT> Out, typename... Ms>

View File

@ -316,9 +316,9 @@ template<typename CharT, std::output_iterator<CharT> Out>
constexpr Out print_separator(Out out, const unit_symbol_formatting& fmt) constexpr Out print_separator(Out out, const unit_symbol_formatting& fmt)
{ {
if (fmt.separator == unit_symbol_separator::half_high_dot) { if (fmt.separator == unit_symbol_separator::half_high_dot) {
if (fmt.encoding != text_encoding::utf8) if (fmt.char_set != character_set::utf8)
MP_UNITS_THROW( MP_UNITS_THROW(
std::invalid_argument("'unit_symbol_separator::half_high_dot' can be only used with 'text_encoding::utf8'")); std::invalid_argument("'unit_symbol_separator::half_high_dot' can be only used with 'character_set::utf8'"));
const std::string_view dot = "" /* U+22C5 DOT OPERATOR */; const std::string_view dot = "" /* U+22C5 DOT OPERATOR */;
out = detail::copy(dot.begin(), dot.end(), out); out = detail::copy(dot.begin(), dot.end(), out);
} else { } else {
@ -339,9 +339,9 @@ template<typename CharT, std::output_iterator<CharT> Out, auto M, auto... Rest>
bool negative_power) bool negative_power)
{ {
auto to_symbol = [&]<typename T>(T v) { auto to_symbol = [&]<typename T>(T v) {
out = copy_symbol<CharT>(get_base(v)._symbol_, fmt.encoding, negative_power, out); out = copy_symbol<CharT>(get_base(v)._symbol_, fmt.char_set, negative_power, out);
constexpr ratio r = get_exponent(T{}); constexpr ratio r = get_exponent(T{});
return copy_symbol_exponent<CharT, abs(r.num), r.den>(fmt.encoding, negative_power, out); return copy_symbol_exponent<CharT, abs(r.num), r.den>(fmt.char_set, negative_power, out);
}; };
return (to_symbol(M), ..., (print_separator<CharT>(out, fmt), to_symbol(Rest))); return (to_symbol(M), ..., (print_separator<CharT>(out, fmt), to_symbol(Rest)));
} }
@ -354,7 +354,7 @@ constexpr Out magnitude_symbol_impl(Out out, const unit_symbol_formatting& fmt)
constexpr auto num_value = _get_value<std::intmax_t>(Num); constexpr auto num_value = _get_value<std::intmax_t>(Num);
if constexpr (num_value != 1) { if constexpr (num_value != 1) {
constexpr auto num = detail::regular<num_value>(); constexpr auto num = detail::regular<num_value>();
out = copy_symbol<CharT>(num, fmt.encoding, false, out); out = copy_symbol<CharT>(num, fmt.char_set, false, out);
numerator = true; numerator = true;
} }
@ -383,7 +383,7 @@ constexpr Out magnitude_symbol_impl(Out out, const unit_symbol_formatting& fmt)
if constexpr (den_value != 1) { if constexpr (den_value != 1) {
constexpr auto den = detail::regular<den_value>(); constexpr auto den = detail::regular<den_value>();
start_denominator(); start_denominator();
out = copy_symbol<CharT>(den, fmt.encoding, negative_power, out); out = copy_symbol<CharT>(den, fmt.char_set, negative_power, out);
denominator = true; denominator = true;
} }
@ -400,10 +400,10 @@ constexpr Out magnitude_symbol_impl(Out out, const unit_symbol_formatting& fmt)
if constexpr (Exp10 != 0) { if constexpr (Exp10 != 0) {
if (numerator || denominator) { if (numerator || denominator) {
constexpr auto mag_multiplier = symbol_text(u8" × " /* U+00D7 MULTIPLICATION SIGN */, " x "); constexpr auto mag_multiplier = symbol_text(u8" × " /* U+00D7 MULTIPLICATION SIGN */, " x ");
out = copy_symbol<CharT>(mag_multiplier, fmt.encoding, negative_power, out); out = copy_symbol<CharT>(mag_multiplier, fmt.char_set, negative_power, out);
} }
constexpr auto exp = symbol_text("10") + detail::superscript<Exp10>(); constexpr auto exp = symbol_text("10") + detail::superscript<Exp10>();
out = copy_symbol<CharT>(exp, fmt.encoding, negative_power, out); out = copy_symbol<CharT>(exp, fmt.char_set, negative_power, out);
} }
return out; return out;

View File

@ -55,14 +55,17 @@ static_assert(std::text_encoding::literal().mib() == std::text_encoding::id::UTF
namespace mp_units { namespace mp_units {
// NOLINTNEXTLINE(readability-enum-initial-value) // NOLINTNEXTLINE(readability-enum-initial-value)
MP_UNITS_EXPORT enum class text_encoding : std::int8_t { MP_UNITS_EXPORT enum class character_set : std::int8_t {
utf8, // µs; m³; L²MT⁻³ utf8, // µs; m³; L²MT⁻³
unicode [[deprecated("Use `utf8` instead")]] = utf8, unicode [[deprecated("Use `utf8` instead")]] = utf8,
portable, // us; m^3; L^2MT^-3 portable, // us; m^3; L^2MT^-3
ascii [[deprecated("Use `portable` instead")]] = portable, ascii [[deprecated("Use `portable` instead")]] = portable,
default_encoding = utf8 default_character_set = utf8,
default_encoding [[deprecated("Use `default_character_set` instead")]] = default_character_set
}; };
using text_encoding [[deprecated("Use `character_set` instead")]] = character_set;
namespace detail { namespace detail {
constexpr bool is_basic_literal_character_set_char(char ch) constexpr bool is_basic_literal_character_set_char(char ch)

View File

@ -785,7 +785,7 @@ template<typename CharT, std::output_iterator<CharT> Out, Unit U>
requires requires { U::_symbol_; } requires requires { U::_symbol_; }
constexpr Out unit_symbol_impl(Out out, U, const unit_symbol_formatting& fmt, bool negative_power) constexpr Out unit_symbol_impl(Out out, U, const unit_symbol_formatting& fmt, bool negative_power)
{ {
return copy_symbol<CharT>(U::_symbol_, fmt.encoding, negative_power, out); return copy_symbol<CharT>(U::_symbol_, fmt.char_set, negative_power, out);
} }
template<typename CharT, std::output_iterator<CharT> Out, auto M, typename U> template<typename CharT, std::output_iterator<CharT> Out, auto M, typename U>
@ -842,7 +842,7 @@ constexpr auto unit_symbol_impl(Out out, const power<F, Num, Den...>&, const uni
bool negative_power) bool negative_power)
{ {
out = unit_symbol_impl<CharT>(out, F{}, fmt, false); // negative power component will be added below if needed out = unit_symbol_impl<CharT>(out, F{}, fmt, false); // negative power component will be added below if needed
return copy_symbol_exponent<CharT, Num, Den...>(fmt.encoding, negative_power, out); return copy_symbol_exponent<CharT, Num, Den...>(fmt.char_set, negative_power, out);
} }
template<typename CharT, std::output_iterator<CharT> Out, typename... Us> template<typename CharT, std::output_iterator<CharT> Out, typename... Us>

View File

@ -23,6 +23,7 @@
#pragma once #pragma once
// IWYU pragma: private, include <mp-units/framework.h> // IWYU pragma: private, include <mp-units/framework.h>
#include <mp-units/bits/hacks.h>
#include <mp-units/bits/module_macros.h> #include <mp-units/bits/module_macros.h>
#include <mp-units/framework/symbol_text.h> #include <mp-units/framework/symbol_text.h>
@ -52,10 +53,15 @@ enum class unit_symbol_separator : std::int8_t {
default_separator = space default_separator = space
}; };
MP_UNITS_DIAGNOSTIC_PUSH
MP_UNITS_DIAGNOSTIC_IGNORE_DEPRECATED
struct unit_symbol_formatting { struct unit_symbol_formatting {
text_encoding encoding = text_encoding::default_encoding; [[deprecated("Use `char_set` instead")]] character_set encoding = character_set::default_character_set;
character_set char_set = encoding;
unit_symbol_solidus solidus = unit_symbol_solidus::default_denominator; unit_symbol_solidus solidus = unit_symbol_solidus::default_denominator;
unit_symbol_separator separator = unit_symbol_separator::default_separator; unit_symbol_separator separator = unit_symbol_separator::default_separator;
}; };
MP_UNITS_DIAGNOSTIC_POP
} // namespace mp_units } // namespace mp_units

View File

@ -32,21 +32,21 @@ namespace {
using namespace mp_units; using namespace mp_units;
using enum text_encoding; using enum character_set;
static_assert(dimension_symbol(dimension_one) == "1"); static_assert(dimension_symbol(dimension_one) == "1");
// base dimensions // base dimensions
static_assert(dimension_symbol(isq::dim_length) == "L"); static_assert(dimension_symbol(isq::dim_length) == "L");
static_assert(dimension_symbol(isq::dim_thermodynamic_temperature) == "Θ"); static_assert(dimension_symbol(isq::dim_thermodynamic_temperature) == "Θ");
static_assert(dimension_symbol<dimension_symbol_formatting{.encoding = portable}>(isq::dim_thermodynamic_temperature) == static_assert(dimension_symbol<dimension_symbol_formatting{.char_set = portable}>(isq::dim_thermodynamic_temperature) ==
"O"); "O");
// derived dimensions // derived dimensions
static_assert(dimension_symbol(isq::speed.dimension) == "LT⁻¹"); static_assert(dimension_symbol(isq::speed.dimension) == "LT⁻¹");
static_assert(dimension_symbol<dimension_symbol_formatting{.encoding = portable}>(isq::speed.dimension) == "LT^-1"); static_assert(dimension_symbol<dimension_symbol_formatting{.char_set = portable}>(isq::speed.dimension) == "LT^-1");
static_assert(dimension_symbol(isq::power.dimension) == "L²MT⁻³"); static_assert(dimension_symbol(isq::power.dimension) == "L²MT⁻³");
static_assert(dimension_symbol<dimension_symbol_formatting{.encoding = portable}>(isq::power.dimension) == "L^2MT^-3"); static_assert(dimension_symbol<dimension_symbol_formatting{.char_set = portable}>(isq::power.dimension) == "L^2MT^-3");
static_assert(dimension_symbol(pow<123>(isq::dim_length)) == "L¹²³"); static_assert(dimension_symbol(pow<123>(isq::dim_length)) == "L¹²³");
static_assert(dimension_symbol(pow<1, 2>(isq::dim_length)) == "L^(1/2)"); static_assert(dimension_symbol(pow<1, 2>(isq::dim_length)) == "L^(1/2)");

View File

@ -38,7 +38,7 @@ using namespace mp_units::si;
using namespace mp_units::iec; using namespace mp_units::iec;
using namespace mp_units::international; using namespace mp_units::international;
using enum text_encoding; using enum character_set;
using enum unit_symbol_solidus; using enum unit_symbol_solidus;
using enum unit_symbol_separator; using enum unit_symbol_separator;
using usf = unit_symbol_formatting; using usf = unit_symbol_formatting;
@ -48,59 +48,59 @@ 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) == "\u2103"); static_assert(unit_symbol(degree_Celsius) == "\u2103");
static_assert(unit_symbol<usf{.encoding = portable}>(degree_Celsius) == "`C"); static_assert(unit_symbol<usf{.char_set = portable}>(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");
// prefixed units // prefixed units
static_assert(unit_symbol(quecto<ohm>) == ""); static_assert(unit_symbol(quecto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(quecto<ohm>) == "qohm"); static_assert(unit_symbol<usf{.char_set = portable}>(quecto<ohm>) == "qohm");
static_assert(unit_symbol(ronto<ohm>) == ""); static_assert(unit_symbol(ronto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(ronto<ohm>) == "rohm"); static_assert(unit_symbol<usf{.char_set = portable}>(ronto<ohm>) == "rohm");
static_assert(unit_symbol(yocto<ohm>) == ""); static_assert(unit_symbol(yocto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(yocto<ohm>) == "yohm"); static_assert(unit_symbol<usf{.char_set = portable}>(yocto<ohm>) == "yohm");
static_assert(unit_symbol(zepto<ohm>) == ""); static_assert(unit_symbol(zepto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(zepto<ohm>) == "zohm"); static_assert(unit_symbol<usf{.char_set = portable}>(zepto<ohm>) == "zohm");
static_assert(unit_symbol(atto<ohm>) == ""); static_assert(unit_symbol(atto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(atto<ohm>) == "aohm"); static_assert(unit_symbol<usf{.char_set = portable}>(atto<ohm>) == "aohm");
static_assert(unit_symbol(femto<ohm>) == ""); static_assert(unit_symbol(femto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(femto<ohm>) == "fohm"); static_assert(unit_symbol<usf{.char_set = portable}>(femto<ohm>) == "fohm");
static_assert(unit_symbol(pico<ohm>) == ""); static_assert(unit_symbol(pico<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(pico<ohm>) == "pohm"); static_assert(unit_symbol<usf{.char_set = portable}>(pico<ohm>) == "pohm");
static_assert(unit_symbol(nano<ohm>) == ""); static_assert(unit_symbol(nano<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(nano<ohm>) == "nohm"); static_assert(unit_symbol<usf{.char_set = portable}>(nano<ohm>) == "nohm");
static_assert(unit_symbol(micro<ohm>) == "µΩ"); static_assert(unit_symbol(micro<ohm>) == "µΩ");
static_assert(unit_symbol<usf{.encoding = portable}>(micro<ohm>) == "uohm"); static_assert(unit_symbol<usf{.char_set = portable}>(micro<ohm>) == "uohm");
static_assert(unit_symbol(milli<ohm>) == ""); static_assert(unit_symbol(milli<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(milli<ohm>) == "mohm"); static_assert(unit_symbol<usf{.char_set = portable}>(milli<ohm>) == "mohm");
static_assert(unit_symbol(centi<ohm>) == ""); static_assert(unit_symbol(centi<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(centi<ohm>) == "cohm"); static_assert(unit_symbol<usf{.char_set = portable}>(centi<ohm>) == "cohm");
static_assert(unit_symbol(deci<ohm>) == ""); static_assert(unit_symbol(deci<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(deci<ohm>) == "dohm"); static_assert(unit_symbol<usf{.char_set = portable}>(deci<ohm>) == "dohm");
static_assert(unit_symbol(deca<ohm>) == "daΩ"); static_assert(unit_symbol(deca<ohm>) == "daΩ");
static_assert(unit_symbol<usf{.encoding = portable}>(deca<ohm>) == "daohm"); static_assert(unit_symbol<usf{.char_set = portable}>(deca<ohm>) == "daohm");
static_assert(unit_symbol(hecto<ohm>) == ""); static_assert(unit_symbol(hecto<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(hecto<ohm>) == "hohm"); static_assert(unit_symbol<usf{.char_set = portable}>(hecto<ohm>) == "hohm");
static_assert(unit_symbol(kilo<ohm>) == ""); static_assert(unit_symbol(kilo<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(kilo<ohm>) == "kohm"); static_assert(unit_symbol<usf{.char_set = portable}>(kilo<ohm>) == "kohm");
static_assert(unit_symbol(mega<ohm>) == ""); static_assert(unit_symbol(mega<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(mega<ohm>) == "Mohm"); static_assert(unit_symbol<usf{.char_set = portable}>(mega<ohm>) == "Mohm");
static_assert(unit_symbol(giga<ohm>) == ""); static_assert(unit_symbol(giga<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(giga<ohm>) == "Gohm"); static_assert(unit_symbol<usf{.char_set = portable}>(giga<ohm>) == "Gohm");
static_assert(unit_symbol(tera<ohm>) == ""); static_assert(unit_symbol(tera<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(tera<ohm>) == "Tohm"); static_assert(unit_symbol<usf{.char_set = portable}>(tera<ohm>) == "Tohm");
static_assert(unit_symbol(peta<ohm>) == ""); static_assert(unit_symbol(peta<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(peta<ohm>) == "Pohm"); static_assert(unit_symbol<usf{.char_set = portable}>(peta<ohm>) == "Pohm");
static_assert(unit_symbol(exa<ohm>) == ""); static_assert(unit_symbol(exa<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(exa<ohm>) == "Eohm"); static_assert(unit_symbol<usf{.char_set = portable}>(exa<ohm>) == "Eohm");
static_assert(unit_symbol(zetta<ohm>) == ""); static_assert(unit_symbol(zetta<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(zetta<ohm>) == "Zohm"); static_assert(unit_symbol<usf{.char_set = portable}>(zetta<ohm>) == "Zohm");
static_assert(unit_symbol(yotta<ohm>) == ""); static_assert(unit_symbol(yotta<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(yotta<ohm>) == "Yohm"); static_assert(unit_symbol<usf{.char_set = portable}>(yotta<ohm>) == "Yohm");
static_assert(unit_symbol(ronna<ohm>) == ""); static_assert(unit_symbol(ronna<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(ronna<ohm>) == "Rohm"); static_assert(unit_symbol<usf{.char_set = portable}>(ronna<ohm>) == "Rohm");
static_assert(unit_symbol(quetta<ohm>) == ""); static_assert(unit_symbol(quetta<ohm>) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(quetta<ohm>) == "Qohm"); static_assert(unit_symbol<usf{.char_set = portable}>(quetta<ohm>) == "Qohm");
static_assert(unit_symbol(kibi<bit>) == "Kibit"); static_assert(unit_symbol(kibi<bit>) == "Kibit");
static_assert(unit_symbol(mebi<bit>) == "Mibit"); static_assert(unit_symbol(mebi<bit>) == "Mibit");
@ -113,13 +113,13 @@ static_assert(unit_symbol(yobi<bit>) == "Yibit");
// scaled units // scaled units
static_assert(unit_symbol(mag<100> * metre) == "[100 m]"); static_assert(unit_symbol(mag<100> * metre) == "[100 m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<100> * metre) == "[100 m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<100> * metre) == "[100 m]");
static_assert(unit_symbol(mag<1000> * metre) == "[10³ m]"); static_assert(unit_symbol(mag<1000> * metre) == "[10³ m]");
static_assert(unit_symbol(mag_power<10, 3> * metre) == "[10³ m]"); static_assert(unit_symbol(mag_power<10, 3> * metre) == "[10³ m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<1000> * metre) == "[10^3 m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<1000> * metre) == "[10^3 m]");
static_assert(unit_symbol(mag<6000> * metre) == "[6 × 10³ m]"); static_assert(unit_symbol(mag<6000> * metre) == "[6 × 10³ m]");
static_assert(unit_symbol(mag<6> * mag_power<10, 3> * metre) == "[6 × 10³ m]"); static_assert(unit_symbol(mag<6> * mag_power<10, 3> * metre) == "[6 × 10³ m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<6000> * metre) == "[6 x 10^3 m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<6000> * metre) == "[6 x 10^3 m]");
static_assert(unit_symbol(mag<10600> * metre) == "[10600 m]"); static_assert(unit_symbol(mag<10600> * metre) == "[10600 m]");
static_assert(unit_symbol(mag<60> * second) == "[60 s]"); static_assert(unit_symbol(mag<60> * second) == "[60 s]");
static_assert(unit_symbol(mag_ratio<1, 18> * metre / second) == "[1/18 m]/s"); static_assert(unit_symbol(mag_ratio<1, 18> * metre / second) == "[1/18 m]/s");
@ -128,18 +128,18 @@ static_assert(unit_symbol(mag_ratio<1, 1800> * metre / second) == "[1/1800 m]/s"
static_assert(unit_symbol(mag_ratio<1, 1800> * (metre / second)) == "[1/1800 m/s]"); static_assert(unit_symbol(mag_ratio<1, 1800> * (metre / second)) == "[1/1800 m/s]");
static_assert(unit_symbol(mag_ratio<1, 18000> * metre / second) == "[1/18 × 10⁻³ m]/s"); static_assert(unit_symbol(mag_ratio<1, 18000> * metre / second) == "[1/18 × 10⁻³ m]/s");
static_assert(unit_symbol(mag_ratio<1, 18000> * (metre / second)) == "[1/18 × 10⁻³ m/s]"); static_assert(unit_symbol(mag_ratio<1, 18000> * (metre / second)) == "[1/18 × 10⁻³ m/s]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag_ratio<1, 18000> * metre / second) == "[1/18 x 10^-3 m]/s"); static_assert(unit_symbol<usf{.char_set = portable}>(mag_ratio<1, 18000> * metre / second) == "[1/18 x 10^-3 m]/s");
static_assert(unit_symbol<usf{.encoding = portable}>(mag_ratio<1, 18000> * (metre / second)) == "[1/18 x 10^-3 m/s]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag_ratio<1, 18000> * (metre / second)) == "[1/18 x 10^-3 m/s]");
// TODO implement all the below // TODO implement all the below
// static_assert(unit_symbol(mag_power<2, 1, 2> * one) == "[2^(1/2)]"); // static_assert(unit_symbol(mag_power<2, 1, 2> * one) == "[2^(1/2)]");
// static_assert(unit_symbol<usf{.encoding = portable}>(mag_power<2, 1, 2> * one) == "[2^(1/2)]"); // static_assert(unit_symbol<usf{.char_set = portable}>(mag_power<2, 1, 2> * one) == "[2^(1/2)]");
// static_assert(unit_symbol(mag_power<2, 1, 2> * m) == "[2^(1/2) m]"); // static_assert(unit_symbol(mag_power<2, 1, 2> * m) == "[2^(1/2) m]");
// static_assert(unit_symbol<usf{.encoding = portable}>(mag_power<2, 1, 2> * m) == "[2^(1/2) m]"); // static_assert(unit_symbol<usf{.char_set = portable}>(mag_power<2, 1, 2> * m) == "[2^(1/2) m]");
// static_assert(unit_symbol(mag<1> / mag_power<2, 1, 2> * one) == "[1/2^(1/2)]"); // static_assert(unit_symbol(mag<1> / mag_power<2, 1, 2> * one) == "[1/2^(1/2)]");
// static_assert(unit_symbol<usf{.encoding = portable}>(mag<1> / mag_power<2, 1, 2> * one) == "[1/2^(1/2)]"); // static_assert(unit_symbol<usf{.char_set = portable}>(mag<1> / mag_power<2, 1, 2> * one) == "[1/2^(1/2)]");
// static_assert(unit_symbol(mag<1> / mag_power<2, 1, 2> * m) == "[1/2^(1/2) m]"); // static_assert(unit_symbol(mag<1> / mag_power<2, 1, 2> * m) == "[1/2^(1/2) m]");
// static_assert(unit_symbol<usf{.encoding = portable}>(mag<1> / mag_power<2, 1, 2> * m) == "[1/2^(1/2) m]"); // static_assert(unit_symbol<usf{.char_set = portable}>(mag<1> / mag_power<2, 1, 2> * m) == "[1/2^(1/2) m]");
// magnitude constants // magnitude constants
#if defined MP_UNITS_COMP_CLANG || MP_UNITS_COMP_CLANG < 18 #if defined MP_UNITS_COMP_CLANG || MP_UNITS_COMP_CLANG < 18
@ -151,47 +151,47 @@ inline constexpr struct e final : mag_constant<"e", std::numbers::e_v<long doubl
} e; } e;
static_assert(unit_symbol(mag<π> * one) == "[π]"); static_assert(unit_symbol(mag<π> * one) == "[π]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<π> * one) == "[pi]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<π> * one) == "[pi]");
static_assert(unit_symbol(mag<π> * metre) == "[π m]"); static_assert(unit_symbol(mag<π> * metre) == "[π m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<π> * metre) == "[pi m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<π> * metre) == "[pi m]");
static_assert(unit_symbol(mag<2> * mag<π> * metre) == "[2 π m]"); static_assert(unit_symbol(mag<2> * mag<π> * metre) == "[2 π m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<2> * mag<π> * metre) == "[2 pi m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<2> * mag<π> * metre) == "[2 pi m]");
static_assert(unit_symbol<usf{.separator = half_high_dot}>(mag<2> * mag<π> * metre) == "[2⋅π m]"); static_assert(unit_symbol<usf{.separator = half_high_dot}>(mag<2> * mag<π> * metre) == "[2⋅π m]");
static_assert(unit_symbol(mag<1> / mag<π> * one) == "[1/π]"); static_assert(unit_symbol(mag<1> / mag<π> * one) == "[1/π]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<1> / mag<π> * one) == "[1/pi]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<1> / mag<π> * one) == "[1/pi]");
static_assert(unit_symbol<usf{.solidus = never}>(mag<1> / mag<π> * one) == "[π⁻¹]"); static_assert(unit_symbol<usf{.solidus = never}>(mag<1> / mag<π> * one) == "[π⁻¹]");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(mag<1> / mag<π> * one) == "[pi^-1]"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(mag<1> / mag<π> * one) == "[pi^-1]");
static_assert(unit_symbol(mag<1> / mag<π> * metre) == "[1/π m]"); static_assert(unit_symbol(mag<1> / mag<π> * metre) == "[1/π m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<1> / mag<π> * metre) == "[1/pi m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<1> / mag<π> * metre) == "[1/pi m]");
static_assert(unit_symbol<usf{.solidus = never}>(mag<1> / mag<π> * metre) == "[π⁻¹ m]"); static_assert(unit_symbol<usf{.solidus = never}>(mag<1> / mag<π> * metre) == "[π⁻¹ m]");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(mag<1> / mag<π> * metre) == "[pi^-1 m]"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(mag<1> / mag<π> * metre) == "[pi^-1 m]");
static_assert(unit_symbol(mag<2> / mag<π> * metre) == "[2/π m]"); static_assert(unit_symbol(mag<2> / mag<π> * metre) == "[2/π m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<2> / mag<π> * metre) == "[2/pi m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<2> / mag<π> * metre) == "[2/pi m]");
static_assert(unit_symbol<usf{.solidus = never}>(mag<2> / mag<π> * metre) == "[2 π⁻¹ m]"); static_assert(unit_symbol<usf{.solidus = never}>(mag<2> / mag<π> * metre) == "[2 π⁻¹ m]");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(mag<2> / mag<π> * metre) == "[2 pi^-1 m]"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(mag<2> / mag<π> * metre) == "[2 pi^-1 m]");
static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(mag<2> / mag<π> * metre) == "[2⋅π⁻¹ m]"); static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(mag<2> / mag<π> * metre) == "[2⋅π⁻¹ m]");
static_assert(unit_symbol(mag<1> / (mag<2> * mag<π>)*metre) == "[2⁻¹ π⁻¹ m]"); static_assert(unit_symbol(mag<1> / (mag<2> * mag<π>)*metre) == "[2⁻¹ π⁻¹ m]");
static_assert(unit_symbol<usf{.solidus = always}>(mag<1> / (mag<2> * mag<π>)*metre) == "[1/(2 π) m]"); static_assert(unit_symbol<usf{.solidus = always}>(mag<1> / (mag<2> * mag<π>)*metre) == "[1/(2 π) m]");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = always}>(mag<1> / (mag<2> * mag<π>)*metre) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = always}>(mag<1> / (mag<2> * mag<π>)*metre) ==
"[1/(2 pi) m]"); "[1/(2 pi) m]");
static_assert(unit_symbol(mag_ratio<1, 2> / mag<π> * metre) == "[2⁻¹ π⁻¹ m]"); static_assert(unit_symbol(mag_ratio<1, 2> / mag<π> * metre) == "[2⁻¹ π⁻¹ m]");
static_assert(unit_symbol<usf{.solidus = always}>(mag_ratio<1, 2> / mag<π> * metre) == "[1/(2 π) m]"); static_assert(unit_symbol<usf{.solidus = always}>(mag_ratio<1, 2> / mag<π> * metre) == "[1/(2 π) m]");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = always}>(mag_ratio<1, 2> / mag<π> * metre) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = always}>(mag_ratio<1, 2> / mag<π> * metre) ==
"[1/(2 pi) m]"); "[1/(2 pi) m]");
static_assert(unit_symbol(mag_ratio<1, 2> * mag<π> * metre) == "[π/2 m]"); static_assert(unit_symbol(mag_ratio<1, 2> * mag<π> * metre) == "[π/2 m]");
static_assert(unit_symbol(mag_power<pi, 2> * one) == "[π²]"); static_assert(unit_symbol(mag_power<pi, 2> * one) == "[π²]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag_power<pi, 2> * one) == "[pi^2]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag_power<pi, 2> * one) == "[pi^2]");
static_assert(unit_symbol(mag_power<pi, 1, 2> * metre) == "[π^(1/2) m]"); static_assert(unit_symbol(mag_power<pi, 1, 2> * metre) == "[π^(1/2) m]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag_power<pi, 1, 2> * metre) == "[pi^(1/2) m]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag_power<pi, 1, 2> * metre) == "[pi^(1/2) m]");
static_assert(unit_symbol(mag<π> * mag<e> * one) == "[e π]"); static_assert(unit_symbol(mag<π> * mag<e> * one) == "[e π]");
static_assert(unit_symbol(mag<e> * mag<π> * one) == "[e π]"); static_assert(unit_symbol(mag<e> * mag<π> * one) == "[e π]");
static_assert(unit_symbol<usf{.encoding = portable}>(mag<π> * mag<e> * one) == "[e pi]"); static_assert(unit_symbol<usf{.char_set = portable}>(mag<π> * mag<e> * one) == "[e pi]");
static_assert(unit_symbol(mag<π> / mag<e> * one) == "[π/e]"); static_assert(unit_symbol(mag<π> / mag<e> * one) == "[π/e]");
static_assert(unit_symbol(mag<1> / mag<e> * mag<π> * one) == "[π/e]"); static_assert(unit_symbol(mag<1> / mag<e> * mag<π> * one) == "[π/e]");
static_assert(unit_symbol<usf{.solidus = never}>(mag<π> / mag<e> * one) == "[π e⁻¹]"); static_assert(unit_symbol<usf{.solidus = never}>(mag<π> / mag<e> * one) == "[π e⁻¹]");
@ -216,38 +216,38 @@ static_assert(unit_symbol(get_common_unit(radian, degree)) == "EQUIV{[1/π°], [
static_assert(unit_symbol(one) == ""); // NOLINT(readability-container-size-empty) static_assert(unit_symbol(one) == ""); // NOLINT(readability-container-size-empty)
static_assert(unit_symbol(percent) == "%"); static_assert(unit_symbol(percent) == "%");
static_assert(unit_symbol(per_mille) == ""); static_assert(unit_symbol(per_mille) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(per_mille) == "%o"); static_assert(unit_symbol<usf{.char_set = portable}>(per_mille) == "%o");
static_assert(unit_symbol(parts_per_million) == "ppm"); static_assert(unit_symbol(parts_per_million) == "ppm");
static_assert(unit_symbol(square(metre)) == ""); static_assert(unit_symbol(square(metre)) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(square(metre)) == "m^2"); static_assert(unit_symbol<usf{.char_set = portable}>(square(metre)) == "m^2");
static_assert(unit_symbol(cubic(metre)) == ""); static_assert(unit_symbol(cubic(metre)) == "");
static_assert(unit_symbol<usf{.encoding = portable}>(cubic(metre)) == "m^3"); static_assert(unit_symbol<usf{.char_set = portable}>(cubic(metre)) == "m^3");
static_assert(unit_symbol(kilo<metre> * metre) == "km m"); static_assert(unit_symbol(kilo<metre> * metre) == "km m");
static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilo<metre> * metre) == "km⋅m"); static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilo<metre> * metre) == "km⋅m");
static_assert(unit_symbol(metre / metre) == ""); // NOLINT(readability-container-size-empty) static_assert(unit_symbol(metre / metre) == ""); // NOLINT(readability-container-size-empty)
static_assert(unit_symbol(kilo<metre> / metre) == "km/m"); static_assert(unit_symbol(kilo<metre> / metre) == "km/m");
static_assert(unit_symbol<usf{.solidus = never}>(kilo<metre> / metre) == "km m⁻¹"); static_assert(unit_symbol<usf{.solidus = never}>(kilo<metre> / metre) == "km m⁻¹");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(kilo<metre> / metre) == "km m^-1"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(kilo<metre> / metre) == "km m^-1");
static_assert(unit_symbol(metre / second) == "m/s"); static_assert(unit_symbol(metre / second) == "m/s");
static_assert(unit_symbol<usf{.solidus = always}>(metre / second) == "m/s"); static_assert(unit_symbol<usf{.solidus = always}>(metre / second) == "m/s");
static_assert(unit_symbol<usf{.solidus = never}>(metre / second) == "m s⁻¹"); static_assert(unit_symbol<usf{.solidus = never}>(metre / second) == "m s⁻¹");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(metre / second) == "m s^-1"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(metre / second) == "m s^-1");
static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(metre / second) == "m⋅s⁻¹"); static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(metre / second) == "m⋅s⁻¹");
static_assert(unit_symbol(metre / square(second)) == "m/s²"); static_assert(unit_symbol(metre / square(second)) == "m/s²");
static_assert(unit_symbol<usf{.encoding = portable}>(metre / square(second)) == "m/s^2"); static_assert(unit_symbol<usf{.char_set = portable}>(metre / square(second)) == "m/s^2");
static_assert(unit_symbol<usf{.solidus = always}>(metre / square(second)) == "m/s²"); static_assert(unit_symbol<usf{.solidus = always}>(metre / square(second)) == "m/s²");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = always}>(metre / square(second)) == "m/s^2"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = always}>(metre / square(second)) == "m/s^2");
static_assert(unit_symbol<usf{.solidus = never}>(metre / square(second)) == "m s⁻²"); static_assert(unit_symbol<usf{.solidus = never}>(metre / square(second)) == "m s⁻²");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(metre / square(second)) == "m s^-2"); static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(metre / square(second)) == "m s^-2");
static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(metre / square(second)) == "m⋅s⁻²"); static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(metre / square(second)) == "m⋅s⁻²");
static_assert(unit_symbol(kilogram * metre / square(second)) == "kg m/s²"); static_assert(unit_symbol(kilogram * metre / square(second)) == "kg m/s²");
static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilogram * metre / square(second)) == "kg⋅m/s²"); static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilogram * metre / square(second)) == "kg⋅m/s²");
static_assert(unit_symbol<usf{.encoding = portable}>(kilogram * metre / square(second)) == "kg m/s^2"); static_assert(unit_symbol<usf{.char_set = portable}>(kilogram * metre / square(second)) == "kg m/s^2");
static_assert(unit_symbol<usf{.solidus = always}>(kilogram * metre / square(second)) == "kg m/s²"); static_assert(unit_symbol<usf{.solidus = always}>(kilogram * metre / square(second)) == "kg m/s²");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = always}>(kilogram * metre / square(second)) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = always}>(kilogram * metre / square(second)) ==
"kg m/s^2"); "kg m/s^2");
static_assert(unit_symbol<usf{.solidus = never}>(kilogram * metre / square(second)) == "kg m s⁻²"); static_assert(unit_symbol<usf{.solidus = never}>(kilogram * metre / square(second)) == "kg m s⁻²");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(kilogram * metre / square(second)) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(kilogram * metre / square(second)) ==
"kg m s^-2"); "kg m s^-2");
static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(kilogram * metre / square(second)) == static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(kilogram * metre / square(second)) ==
"kg⋅m⋅s⁻²"); "kg⋅m⋅s⁻²");
@ -255,12 +255,12 @@ static_assert(unit_symbol(one / metre / square(second)) == "m⁻¹ s⁻²");
static_assert(unit_symbol<usf{.solidus = always}>(one / metre / square(second)) == "1/(m s²)"); static_assert(unit_symbol<usf{.solidus = always}>(one / metre / square(second)) == "1/(m s²)");
static_assert(unit_symbol(kilogram / metre / square(second)) == "kg m⁻¹ s⁻²"); static_assert(unit_symbol(kilogram / metre / square(second)) == "kg m⁻¹ s⁻²");
static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilogram / metre / square(second)) == "kg⋅m⁻¹⋅s⁻²"); static_assert(unit_symbol<usf{.separator = half_high_dot}>(kilogram / metre / square(second)) == "kg⋅m⁻¹⋅s⁻²");
static_assert(unit_symbol<usf{.encoding = portable}>(kilogram / metre / square(second)) == "kg m^-1 s^-2"); static_assert(unit_symbol<usf{.char_set = portable}>(kilogram / metre / square(second)) == "kg m^-1 s^-2");
static_assert(unit_symbol<usf{.solidus = always}>(kilogram / metre / square(second)) == "kg/(m s²)"); static_assert(unit_symbol<usf{.solidus = always}>(kilogram / metre / square(second)) == "kg/(m s²)");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = always}>(kilogram / metre / square(second)) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = always}>(kilogram / metre / square(second)) ==
"kg/(m s^2)"); "kg/(m s^2)");
static_assert(unit_symbol<usf{.solidus = never}>(kilogram / metre / square(second)) == "kg m⁻¹ s⁻²"); static_assert(unit_symbol<usf{.solidus = never}>(kilogram / metre / square(second)) == "kg m⁻¹ s⁻²");
static_assert(unit_symbol<usf{.encoding = portable, .solidus = never}>(kilogram / metre / square(second)) == static_assert(unit_symbol<usf{.char_set = portable, .solidus = never}>(kilogram / metre / square(second)) ==
"kg m^-1 s^-2"); "kg m^-1 s^-2");
static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(kilogram / metre / square(second)) == static_assert(unit_symbol<usf{.solidus = never, .separator = half_high_dot}>(kilogram / metre / square(second)) ==
"kg⋅m⁻¹⋅s⁻²"); "kg⋅m⁻¹⋅s⁻²");