diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index 05712db6..573f2e7b 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -582,19 +582,16 @@ struct formatter< template auto format(map_type& map, FormatContext& ctx) const -> decltype(ctx.out()) { - auto mapper = detail::range_mapper>(); auto out = ctx.out(); - auto it = detail::range_begin(map); - auto end = detail::range_end(map); - basic_string_view open = detail::string_literal{}; if (!no_delimiters_) out = detail::copy(open, out); int i = 0; + auto mapper = detail::range_mapper>(); basic_string_view sep = detail::string_literal{}; - for (; it != end; ++it) { + for (auto&& value : map) { if (i > 0) out = detail::copy(sep, out); ctx.advance_to(out); - detail::for_each2(formatters_, mapper.map(*it), + detail::for_each2(formatters_, mapper.map(value), detail::format_tuple_element{ 0, ctx, detail::string_literal{}}); ++i;