Deprecate memory buffer overload of format_to

This commit is contained in:
Victor Zverovich 2021-05-30 12:59:56 -07:00
parent 07039f4b19
commit e77b22d6da
2 changed files with 7 additions and 6 deletions

View File

@ -2835,8 +2835,9 @@ inline auto format(const Locale& loc, format_string<T...> fmt, T&&... args)
}
template <typename... T, size_t SIZE, typename Allocator>
inline auto format_to(basic_memory_buffer<char, SIZE, Allocator>& buf,
format_string<T...> fmt, T&&... args) -> appender {
FMT_DEPRECATED auto format_to(basic_memory_buffer<char, SIZE, Allocator>& buf,
format_string<T...> fmt, T&&... args)
-> appender {
detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...));
return appender(buf);
}

View File

@ -1534,7 +1534,7 @@ TEST(format_test, format_examples) {
EXPECT_EQ("42", fmt::format("{}", 42));
memory_buffer out;
format_to(out, "The answer is {}.", 42);
format_to(std::back_inserter(out), "The answer is {}.", 42);
EXPECT_EQ("The answer is 42.", to_string(out));
const char* filename = "nonexistent";
@ -1662,8 +1662,8 @@ TEST(format_test, join_bytes) {
#endif
std::string vformat_message(int id, const char* format, fmt::format_args args) {
fmt::memory_buffer buffer;
format_to(buffer, "[{}] ", id);
auto buffer = fmt::memory_buffer();
format_to(fmt::appender(buffer), "[{}] ", id);
vformat_to(fmt::appender(buffer), format, args);
return to_string(buffer);
}
@ -1892,7 +1892,7 @@ TEST(format_test, format_to) {
TEST(format_test, format_to_memory_buffer) {
auto buf = fmt::basic_memory_buffer<char, 100>();
fmt::format_to(buf, "{}", "foo");
fmt::format_to(fmt::appender(buf), "{}", "foo");
EXPECT_EQ("foo", to_string(buf));
}