diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 75b33313..215f50bc 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -383,7 +383,7 @@ OutputIt format_default(OutputIt out, T value) { template OutputIt format_default(OutputIt out, double value) { - writer w(out); + basic_writer> w(out); w.write(value); return w.out(); } diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7836255f..4472768b 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -152,13 +152,10 @@ FMT_FUNC void format_error_code(internal::buffer& out, int error_code, ++error_code_size; } error_code_size += internal::to_unsigned(internal::count_digits(abs_value)); - internal::writer w(out); - if (message.size() <= inline_buffer_size - error_code_size) { - w.write(message); - w.write(SEP); - } - w.write(ERROR_STR); - w.write(error_code); + auto it = std::back_inserter(out); + if (message.size() <= inline_buffer_size - error_code_size) + format_to(it, "{}{}", message, SEP); + format_to(it, "{}{}", ERROR_STR, error_code); assert(out.size() <= inline_buffer_size); } @@ -1348,10 +1345,7 @@ FMT_FUNC void format_system_error(internal::buffer& out, int error_code, int result = internal::safe_strerror(error_code, system_message, buf.size()); if (result == 0) { - internal::writer w(out); - w.write(message); - w.write(": "); - w.write(system_message); + format_to(std::back_inserter(out), "{}: {}", message, system_message); return; } if (result != ERANGE) diff --git a/include/fmt/format.h b/include/fmt/format.h index d9b3d8c2..8395d32e 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1751,8 +1751,6 @@ template class basic_writer { } }; -using writer = basic_writer>; - template struct is_integral : std::is_integral {}; template <> struct is_integral : std::true_type {}; template <> struct is_integral : std::true_type {}; diff --git a/src/os.cc b/src/os.cc index 10a372a4..328abcee 100644 --- a/src/os.cc +++ b/src/os.cc @@ -124,10 +124,7 @@ void internal::format_windows_error(internal::buffer& out, int error_code, if (result != 0) { utf16_to_utf8 utf8_message; if (utf8_message.convert(system_message) == ERROR_SUCCESS) { - internal::writer w(out); - w.write(message); - w.write(": "); - w.write(utf8_message); + format_to(std::back_inserter(out), "{}: {}", message, utf8_message); return; } break; diff --git a/test/format-test.cc b/test/format-test.cc index 66622d7e..46629d1d 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -479,13 +479,6 @@ TEST(StringViewTest, Ctor) { EXPECT_EQ(4u, string_view(std::string("defg")).size()); } -TEST(WriterTest, Data) { - memory_buffer buf; - fmt::internal::writer w(buf); - w.write(42); - EXPECT_EQ("42", to_string(buf)); -} - TEST(WriterTest, WriteInt) { CHECK_WRITE(42); CHECK_WRITE(-42); @@ -548,16 +541,14 @@ TEST(WriterTest, WriteLongDouble) { TEST(WriterTest, WriteDoubleAtBufferBoundary) { memory_buffer buf; - fmt::internal::writer writer(buf); - for (int i = 0; i < 100; ++i) writer.write(1.23456789); + for (int i = 0; i < 100; ++i) fmt::format_to(buf, "{}", 1.23456789); } TEST(WriterTest, WriteDoubleWithFilledBuffer) { memory_buffer buf; - fmt::internal::writer writer(buf); // Fill the buffer. - for (int i = 0; i < fmt::inline_buffer_size; ++i) writer.write(' '); - writer.write(1.2); + for (int i = 0; i < fmt::inline_buffer_size; ++i) fmt::format_to(buf, " "); + fmt::format_to(buf, "{}", 1.2); fmt::string_view sv(buf.data(), buf.size()); sv.remove_prefix(fmt::inline_buffer_size); EXPECT_EQ("1.2", sv);