Fix format_to formatting to wmemory_buffer

This commit is contained in:
Victor Zverovich 2018-09-21 07:56:30 -07:00
parent dc69cc45d2
commit cb122a4d03
2 changed files with 11 additions and 7 deletions

View File

@ -3457,16 +3457,17 @@ inline wformat_context::iterator vformat_to(
return vformat_to<arg_formatter<range>>(buf, format_str, args); return vformat_to<arg_formatter<range>>(buf, format_str, args);
} }
template <typename String, typename... Args, template <
std::size_t SIZE = inline_buffer_size> typename String, typename... Args,
inline format_context::iterator format_to( std::size_t SIZE = inline_buffer_size,
basic_memory_buffer<char, SIZE> &buf, const String &format_str, typename Char = typename internal::format_string_traits<String>::char_type>
inline typename buffer_context<Char>::type::iterator format_to(
basic_memory_buffer<Char, SIZE> &buf, const String &format_str,
const Args & ... args) { const Args & ... args) {
internal::check_format_string<Args...>(format_str); internal::check_format_string<Args...>(format_str);
typedef typename internal::format_string_traits<String>::char_type char_t;
return vformat_to( return vformat_to(
buf, basic_string_view<char_t>(format_str), buf, basic_string_view<Char>(format_str),
make_format_args<typename buffer_context<char_t>::type>(args...)); make_format_args<typename buffer_context<Char>::type>(args...));
} }
template <typename OutputIt, typename Char = char> template <typename OutputIt, typename Char = char>

View File

@ -692,6 +692,9 @@ TEST(FormatToTest, FormatToMemoryBuffer) {
fmt::basic_memory_buffer<char, 100> buffer; fmt::basic_memory_buffer<char, 100> buffer;
fmt::format_to(buffer, "{}", "foo"); fmt::format_to(buffer, "{}", "foo");
EXPECT_EQ("foo", to_string(buffer)); EXPECT_EQ("foo", to_string(buffer));
fmt::wmemory_buffer wbuffer;
fmt::format_to(wbuffer, L"{}", L"foo");
EXPECT_EQ(L"foo", to_string(wbuffer));
} }
TEST(FormatterTest, Escape) { TEST(FormatterTest, Escape) {