Skip to content

Commit

Permalink
Fix regression in #3710 (#3968)
Browse files Browse the repository at this point in the history
Regression introduced in 11f2f30
Already have a test for this, but needed to make __cpp_lib_ranges
smaller to enable it
  • Loading branch information
Arghnews committed May 23, 2024
1 parent b817610 commit fc723fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ struct range_formatter<
for (; it != end; ++it) {
if (i > 0) out = detail::copy<Char>(separator_, out);
ctx.advance_to(out);
out = underlying_.format(mapper.map(*it), ctx);
auto&& item = *it; // Need an lvalue
out = underlying_.format(mapper.map(item), ctx);
++i;
}
out = detail::copy<Char>(closing_bracket_, out);
Expand Down
2 changes: 1 addition & 1 deletion test/ranges-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ TEST(ranges_test, format_join_adl_begin_end) {

#endif // FMT_RANGES_TEST_ENABLE_JOIN

#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 202302L
#if defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 202207L
TEST(ranges_test, nested_ranges) {
auto l = std::list{1, 2, 3};
auto r = std::views::iota(0, 3) | std::views::transform([&l](auto i) {
Expand Down

0 comments on commit fc723fd

Please sign in to comment.