Skip to content

Commit

Permalink
Fix for issue fmtlib#3241
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Shchapov <[email protected]>
  • Loading branch information
phprus committed Dec 23, 2022
1 parent 6a186bc commit 2a0c98c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ template <typename Char, typename T, typename U,
FMT_CONSTEXPR auto copy_str(T* begin, T* end, U* out) -> U* {
if (is_constant_evaluated()) return copy_str<Char, T*, U*>(begin, end, out);
auto size = to_unsigned(end - begin);
memcpy(out, begin, size * sizeof(U));
if (size > 0) memcpy(out, begin, size * sizeof(U));
return out + size;
}

Expand Down
4 changes: 4 additions & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,10 @@ TEST(format_test, to_string) {
#if FMT_USE_FLOAT128
EXPECT_EQ(fmt::to_string(__float128(0.5)), "0.5");
#endif

#if defined(FMT_USE_STRING_VIEW) && FMT_CPLUSPLUS >= 201703L
EXPECT_EQ(fmt::to_string(std::string_view()), "");
#endif
}

TEST(format_test, output_iterators) {
Expand Down

0 comments on commit 2a0c98c

Please sign in to comment.