mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 03:07:36 +02:00
Use p2197 format for complex by default
This commit is contained in:
@ -595,8 +595,8 @@ struct formatter<std::complex<F>, Char> : nested_formatter<F, Char> {
|
|||||||
|
|
||||||
template <typename OutputIt>
|
template <typename OutputIt>
|
||||||
FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
|
FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
|
||||||
auto format =
|
auto format = detail::string_literal<Char, '(', '{', '}', '+', '{', '}',
|
||||||
detail::string_literal<Char, '(', '{', '}', ',', '{', '}', ')'>{};
|
'i', ')'>{};
|
||||||
return fmt::format_to(out, basic_string_view<Char>(format),
|
return fmt::format_to(out, basic_string_view<Char>(format),
|
||||||
f->nested(c.real()), f->nested(c.imag()));
|
f->nested(c.real()), f->nested(c.imag()));
|
||||||
}
|
}
|
||||||
|
@ -66,9 +66,9 @@ TEST(std_test, thread_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(std_test, complex) {
|
TEST(std_test, complex) {
|
||||||
EXPECT_EQ(fmt::format("{}", std::complex<double>(1, 2.2)), "(1,2.2)");
|
EXPECT_EQ(fmt::format("{}", std::complex<double>(1, 2.2)), "(1+2.2i)");
|
||||||
EXPECT_EQ(fmt::format("{:>20.2f}", std::complex<double>(1, 2.2)),
|
EXPECT_EQ(fmt::format("{:>20.2f}", std::complex<double>(1, 2.2)),
|
||||||
" (1.00,2.20)");
|
" (1.00+2.20i)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cpp_lib_source_location
|
#ifdef __cpp_lib_source_location
|
||||||
|
@ -584,9 +584,9 @@ TEST(locale_test, sign) {
|
|||||||
|
|
||||||
TEST(std_test_xchar, complex) {
|
TEST(std_test_xchar, complex) {
|
||||||
auto s = fmt::format(L"{}", std::complex<double>(1, 2));
|
auto s = fmt::format(L"{}", std::complex<double>(1, 2));
|
||||||
EXPECT_EQ(s, L"(1,2)");
|
EXPECT_EQ(s, L"(1+2i)");
|
||||||
EXPECT_EQ(fmt::format(L"{:.2f}", std::complex<double>(1, 2)), L"(1.00,2.00)");
|
EXPECT_EQ(fmt::format(L"{:.2f}", std::complex<double>(1, 2)), L"(1.00+2.00i)");
|
||||||
EXPECT_EQ(fmt::format(L"{:8}", std::complex<double>(1, 2)), L"(1,2) ");
|
EXPECT_EQ(fmt::format(L"{:8}", std::complex<double>(1, 2)), L"(1+2i) ");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(std_test_xchar, optional) {
|
TEST(std_test_xchar, optional) {
|
||||||
|
Reference in New Issue
Block a user