feat: do not print space between a number and percent or per_mille

This commit is contained in:
Mateusz Pusz
2024-01-19 21:20:33 +01:00
parent e51a5f6e8e
commit 1df2cc7b58
2 changed files with 7 additions and 2 deletions

View File

@ -836,6 +836,11 @@ constexpr Out unit_symbol_impl(Out out, const derived_unit<Expr...>&, unit_symbo
template<Unit auto U>
inline constexpr bool space_before_unit_symbol = true;
template<>
inline constexpr bool space_before_unit_symbol<percent> = false;
template<>
inline constexpr bool space_before_unit_symbol<per_mille> = false;
template<typename CharT = char, std::output_iterator<CharT> Out, Unit U>
constexpr Out unit_symbol_to(Out out, U u, unit_symbol_formatting fmt = unit_symbol_formatting{})
{

View File

@ -237,7 +237,7 @@ TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]")
SECTION("fmt with default format {} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{}", q) == os.str()); }
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{:%Q %q}", q) == os.str()); }
SECTION("fmt with format {:%Q %q} on a quantity") { CHECK(MP_UNITS_STD_FMT::format("{:%Q %q}", q) == "15 %"); }
}
SECTION("radians")