Skip to content

Commit f77fa93

Browse files
committed
Update fmt
1 parent 4203642 commit f77fa93

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

third_party/fmt/include/fmt/xchar.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,18 @@ inline auto vformat_to_n(OutputIt out, size_t n, basic_string_view<Char> fmt,
279279
return {buf.out(), buf.count()};
280280
}
281281

282+
template <typename OutputIt, typename... T,
283+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, wchar_t>::value)>
284+
FMT_INLINE auto format_to_n(OutputIt out, size_t n, wformat_string<T...> fmt,
285+
T&&... args) -> format_to_n_result<OutputIt> {
286+
return vformat_to_n(out, n, fmt.get(), fmt::make_wformat_args(args...));
287+
}
288+
282289
template <typename OutputIt, typename S, typename... T,
283290
typename Char = detail::format_string_char_t<S>,
284-
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
285-
detail::is_exotic_char<Char>::value)>
291+
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value &&
292+
!std::is_same<Char, char>::value &&
293+
!std::is_same<Char, wchar_t>::value)>
286294
inline auto format_to_n(OutputIt out, size_t n, const S& fmt, T&&... args)
287295
-> format_to_n_result<OutputIt> {
288296
return vformat_to_n(out, n, fmt::basic_string_view<Char>(fmt),

third_party/fmt/test/xchar-test.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,26 @@ TEST(format_test, wide_format_to_n) {
146146
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
147147
}
148148

149+
TEST(format_test, wide_format_to_n_runtime) {
150+
wchar_t buffer[4];
151+
buffer[3] = L'x';
152+
auto result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}"), 12345);
153+
EXPECT_EQ(5u, result.size);
154+
EXPECT_EQ(buffer + 3, result.out);
155+
EXPECT_EQ(L"123x", fmt::wstring_view(buffer, 4));
156+
buffer[0] = L'x';
157+
buffer[1] = L'x';
158+
buffer[2] = L'x';
159+
result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}"), L'A');
160+
EXPECT_EQ(1u, result.size);
161+
EXPECT_EQ(buffer + 1, result.out);
162+
EXPECT_EQ(L"Axxx", fmt::wstring_view(buffer, 4));
163+
result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}{} "), L'B', L'C');
164+
EXPECT_EQ(3u, result.size);
165+
EXPECT_EQ(buffer + 3, result.out);
166+
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
167+
}
168+
149169
TEST(xchar_test, named_arg_udl) {
150170
using namespace fmt::literals;
151171
auto udl_a =

third_party/software-bill-of-materials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bazel-toolchain-795d76fd03e0b17c0961f0981a8512a00cba4fa2
1515
boringssl-fcf70a1a66f4cd000ab9acefb91e3b380fe0984b
1616
Catch2-ccc49ba66484d881087fdc87fcc68b488c49bca4
1717
cpuinfo-7607ca500436b37ad23fb8d18614bec7796b68a7
18-
fmt-4968433a6abecbbf7e72e97188926586a7fd0662
18+
fmt-ea85b81ccdb28dda636351e80a1888b1d279f325
1919
gflags-03a4842c9c6aaef438d7bf0c84e8a62c8064992b
2020
glog-570c7e4e1dd197e9ae2777152b87a5ea9e06bcac
2121
googletest-f38004c441a2d7ba004853bb0863ff2b2571f461

0 commit comments

Comments
 (0)