Update format_to taking a buffer and remove undocumented vformat_to overload
This commit is contained in:
parent
832ec098fc
commit
11a14db286
@ -2795,25 +2795,14 @@ template <typename Locale, typename... T,
|
||||
FMT_ENABLE_IF(detail::is_locale<Locale>::value)>
|
||||
inline std::string format(const Locale& loc, format_string<T...> fmt,
|
||||
T&&... args) {
|
||||
return vformat(loc, fmt, fmt::make_format_args(args...));
|
||||
return vformat(loc, string_view(fmt), fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>,
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
inline void vformat_to(
|
||||
detail::buffer<Char>& buf, const S& format_str,
|
||||
basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> args) {
|
||||
return detail::vformat_to(buf, to_string_view(format_str), args);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args, typename Char, size_t SIZE,
|
||||
typename Allocator, FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
inline auto format_to(basic_memory_buffer<Char, SIZE, Allocator>& buf,
|
||||
const S& format_str, Args&&... args) ->
|
||||
typename buffer_context<Char>::iterator {
|
||||
const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
|
||||
detail::vformat_to(buf, to_string_view(format_str), vargs);
|
||||
return detail::buffer_appender<Char>(buf);
|
||||
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 {
|
||||
detail::vformat_to(buf, string_view(fmt), fmt::make_format_args(args...));
|
||||
return appender(buf);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Locale,
|
||||
@ -2823,7 +2812,7 @@ auto vformat_to(OutputIt out, const Locale& loc, string_view fmt,
|
||||
format_args args) -> OutputIt {
|
||||
using detail::get_buffer;
|
||||
auto&& buf = get_buffer<char>(out);
|
||||
detail::vformat_to(buf, string_view(fmt), args, detail::locale_ref(loc));
|
||||
detail::vformat_to(buf, fmt, args, detail::locale_ref(loc));
|
||||
return detail::get_iterator(buf);
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,16 @@ inline auto format_to(OutputIt out, const S& fmt, Args&&... args) -> OutputIt {
|
||||
return vformat_to(out, to_string_view(fmt), vargs);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args, typename Char, size_t SIZE,
|
||||
typename Allocator, FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
FMT_DEPRECATED auto format_to(basic_memory_buffer<Char, SIZE, Allocator>& buf,
|
||||
const S& format_str, Args&&... args) ->
|
||||
typename buffer_context<Char>::iterator {
|
||||
const auto& vargs = fmt::make_args_checked<Args...>(format_str, args...);
|
||||
detail::vformat_to(buf, to_string_view(format_str), vargs);
|
||||
return detail::buffer_appender<Char>(buf);
|
||||
}
|
||||
|
||||
template <typename Locale, typename S, typename OutputIt, typename... Args,
|
||||
typename Char = char_t<S>,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
|
||||
|
@ -308,7 +308,7 @@ TEST(format_impl_test, format_error_code) {
|
||||
std::string msg = "error 42", sep = ": ";
|
||||
{
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "garbage");
|
||||
format_to(fmt::appender(buffer), "garbage");
|
||||
fmt::detail::format_error_code(buffer, 42, "test");
|
||||
EXPECT_EQ("test: " + msg, to_string(buffer));
|
||||
}
|
||||
|
@ -1664,7 +1664,7 @@ TEST(format_test, join_bytes) {
|
||||
std::string vformat_message(int id, const char* format, fmt::format_args args) {
|
||||
fmt::memory_buffer buffer;
|
||||
format_to(buffer, "[{}] ", id);
|
||||
vformat_to(buffer, format, args);
|
||||
vformat_to(fmt::appender(buffer), format, args);
|
||||
return to_string(buffer);
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,6 @@ TEST(wchar_test, vformat_to) {
|
||||
EXPECT_EQ(L"42", w);
|
||||
}
|
||||
|
||||
TEST(wchar_test, format_to_memory_buffer) {
|
||||
auto buf = fmt::wmemory_buffer();
|
||||
fmt::format_to(buf, L"{}", L"foo");
|
||||
EXPECT_EQ(L"foo", to_string(buf));
|
||||
}
|
||||
|
||||
TEST(format_test, wide_format_to_n) {
|
||||
wchar_t buffer[4];
|
||||
buffer[3] = L'x';
|
||||
|
Loading…
Reference in New Issue
Block a user