From 6b482717e65839f1fa02d2399ecb80098b452d18 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 19 Mar 2024 07:55:45 +0900 Subject: [PATCH] Use p2197 format for complex by default --- include/fmt/std.h | 4 ++-- test/std-test.cc | 4 ++-- test/xchar-test.cc | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/fmt/std.h b/include/fmt/std.h index 3e38eef70ca2..2d6012e3dc1f 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -595,8 +595,8 @@ struct formatter, Char> : nested_formatter { template FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt { - auto format = - detail::string_literal{}; + auto format = detail::string_literal{}; return fmt::format_to(out, basic_string_view(format), f->nested(c.real()), f->nested(c.imag())); } diff --git a/test/std-test.cc b/test/std-test.cc index b3f62d5cb131..3fbcedf5764d 100644 --- a/test/std-test.cc +++ b/test/std-test.cc @@ -66,9 +66,9 @@ TEST(std_test, thread_id) { } TEST(std_test, complex) { - EXPECT_EQ(fmt::format("{}", std::complex(1, 2.2)), "(1,2.2)"); + EXPECT_EQ(fmt::format("{}", std::complex(1, 2.2)), "(1+2.2i)"); EXPECT_EQ(fmt::format("{:>20.2f}", std::complex(1, 2.2)), - " (1.00,2.20)"); + " (1.00+2.20i)"); } #ifdef __cpp_lib_source_location diff --git a/test/xchar-test.cc b/test/xchar-test.cc index b552f85b750c..8f15a3479766 100644 --- a/test/xchar-test.cc +++ b/test/xchar-test.cc @@ -584,9 +584,9 @@ TEST(locale_test, sign) { TEST(std_test_xchar, complex) { auto s = fmt::format(L"{}", std::complex(1, 2)); - EXPECT_EQ(s, L"(1,2)"); - EXPECT_EQ(fmt::format(L"{:.2f}", std::complex(1, 2)), L"(1.00,2.00)"); - EXPECT_EQ(fmt::format(L"{:8}", std::complex(1, 2)), L"(1,2) "); + EXPECT_EQ(s, L"(1+2i)"); + EXPECT_EQ(fmt::format(L"{:.2f}", std::complex(1, 2)), L"(1.00+2.00i)"); + EXPECT_EQ(fmt::format(L"{:8}", std::complex(1, 2)), L"(1+2i) "); } TEST(std_test_xchar, optional) {