From 3d6053e25c28c77fc2f3cb4f06fe648cbb8af049 Mon Sep 17 00:00:00 2001 From: Cristi Date: Thu, 7 Jan 2021 18:17:11 +0200 Subject: [PATCH 1/3] Ranges copy wchar_t --- include/fmt/ranges.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 0ebf96526442..4c04f9ea34a7 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -67,6 +67,12 @@ OutputIterator copy(char ch, OutputIterator out) { return out; } +template +OutputIterator copy(wchar_t ch, OutputIterator out) { + *out++ = ch; + return out; +} + /// Return true value if T has std::string interface, like std::string_view. template class is_like_std_string { template From 8252be63b3d26c77c3f3b819c4ce65b54576d699 Mon Sep 17 00:00:00 2001 From: Cristi Date: Thu, 7 Jan 2021 23:03:47 +0200 Subject: [PATCH 2/3] arg_join formatter not working for wide strings --- include/fmt/format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 32b42dd54c54..ee01391c98cd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3720,7 +3720,7 @@ struct formatter, Char> { private: using value_type = typename std::iterator_traits::value_type; using formatter_type = - conditional_t::value, + conditional_t>::value, formatter, detail::fallback_formatter>; From ac77058a8c8b6b6fb61ce296ed29fdaba4c54e84 Mon Sep 17 00:00:00 2001 From: Cristi Date: Thu, 15 Apr 2021 19:06:33 +0300 Subject: [PATCH 3/3] Added ranges wide string tests --- test/ranges-test.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/ranges-test.cc b/test/ranges-test.cc index 30ed97f21233..8fee3e14e6b8 100644 --- a/test/ranges-test.cc +++ b/test/ranges-test.cc @@ -224,6 +224,25 @@ TEST(RangesTest, JoinTuple) { EXPECT_EQ("4", fmt::format("{}", fmt::join(t4, "/"))); } +TEST(RangesTest, WideStringJoinTuple) { + // Value tuple args + std::tuple t1 = std::make_tuple('a', 1, 2.0f); + EXPECT_EQ(L"(a, 1, 2)", fmt::format(L"({})", fmt::join(t1, L", "))); + + // Testing lvalue tuple args + int x = 4; + std::tuple t2{'b', x}; + EXPECT_EQ(L"b + 4", fmt::format(L"{}", fmt::join(t2, L" + "))); + + // Empty tuple + std::tuple<> t3; + EXPECT_EQ(L"", fmt::format(L"{}", fmt::join(t3, L"|"))); + + // Single element tuple + std::tuple t4{4.0f}; + EXPECT_EQ(L"4", fmt::format(L"{}", fmt::join(t4, L"/"))); +} + TEST(RangesTest, JoinInitializerList) { EXPECT_EQ("1, 2, 3", fmt::format("{}", fmt::join({1, 2, 3}, ", "))); EXPECT_EQ("fmt rocks !",