Skip to content

Commit c0dac83

Browse files
committed
Use p2197 format for complex by default
1 parent bb882c0 commit c0dac83

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

include/fmt/std.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,8 @@ struct formatter<std::complex<F>, Char> : nested_formatter<F, Char> {
595595

596596
template <typename OutputIt>
597597
FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
598-
auto format =
599-
detail::string_literal<Char, '(', '{', '}', ',', '{', '}', ')'>{};
598+
auto format = detail::string_literal<Char, '(', '{', '}', '+', '{', '}',
599+
'i', ')'>{};
600600
return fmt::format_to(out, basic_string_view<Char>(format),
601601
f->nested(c.real()), f->nested(c.imag()));
602602
}

test/std-test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ TEST(std_test, thread_id) {
6666
}
6767

6868
TEST(std_test, complex) {
69-
EXPECT_EQ(fmt::format("{}", std::complex<double>(1, 2.2)), "(1,2.2)");
69+
EXPECT_EQ(fmt::format("{}", std::complex<double>(1, 2.2)), "(1+2.2i)");
7070
EXPECT_EQ(fmt::format("{:>20.2f}", std::complex<double>(1, 2.2)),
71-
" (1.00,2.20)");
71+
" (1.00+2.20i)");
7272
}
7373

7474
#ifdef __cpp_lib_source_location

test/xchar-test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ TEST(locale_test, sign) {
584584

585585
TEST(std_test_xchar, complex) {
586586
auto s = fmt::format(L"{}", std::complex<double>(1, 2));
587-
EXPECT_EQ(s, L"(1,2)");
588-
EXPECT_EQ(fmt::format(L"{:.2f}", std::complex<double>(1, 2)), L"(1.00,2.00)");
589-
EXPECT_EQ(fmt::format(L"{:8}", std::complex<double>(1, 2)), L"(1,2) ");
587+
EXPECT_EQ(s, L"(1+2i)");
588+
EXPECT_EQ(fmt::format(L"{:.2f}", std::complex<double>(1, 2)), L"(1.00+2.00i)");
589+
EXPECT_EQ(fmt::format(L"{:8}", std::complex<double>(1, 2)), L"(1+2i) ");
590590
}
591591

592592
TEST(std_test_xchar, optional) {

0 commit comments

Comments
 (0)