Repository: fmtlib/fmt
File: include/fmt/ranges.h (C/C++)

Code before:
    }
    basic_string_view<Char> close = detail::string_literal<Char, '}'>{};
    if (!no_delimiters_) out = detail::copy<Char>(close, out);
    return out;
  }
};

// A string formatter.
template <typename R, typename Char>
struct formatter<
    R, Char,
    enable_if_t<range_format_kind<R, Char>::value == range_format::string>> {
 private:
  using range_type = detail::maybe_const_range<R>;
  formatter<detail::std_string_view<Char>, Char> range_formatter_;

 public:
  FMT_CONSTEXPR formatter() {}

  template <typename ParseContext>
  FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
    return range_formatter_.parse(ctx);
  }

  template <typename FormatContext>
  auto format(range_type& range, FormatContext& ctx) const
      -> decltype(ctx.out()) {
    return range_formatter_.format(detail::std_string_view<Char>(range), ctx);
  }
};

template <typename It, typename Sentinel, typename Char = char>
struct join_view : detail::view {
  It begin;
  Sentinel end;
  basic_string_view<Char> sep;

  join_view(It b, Sentinel e, basic_string_view<Char> s)
      : begin(std::move(b)), end(e), sep(s) {}
};

template <typename It, typename Sentinel, typename Char>
struct formatter<join_view<It, Sentinel, Char>, Char> {
 private:
  using value_type =
#ifdef __cpp_lib_ranges
      std::iter_value_t<It>;
#else
      typename std::iterator_traits<It>::value_type;
#endif
  formatter<remove_cvref_t<value_type>, Char> value_formatter_;

Review comment (suggestion):
This is inconsistent with the standard formatter: https://eel.is/c++draft/format.range.fmtstr. The range should be formatted as a string without conversion to a `string_view`.

Code after:
    basic_string_view<Char> sep = detail::string_literal<Char, ',', ' '>{};
    for (auto&& value : map) {
      if (i > 0) out = detail::copy<Char>(sep, out);
      ctx.advance_to(out);
      detail::for_each2(formatters_, mapper.map(value),
                        detail::format_tuple_element<FormatContext>{
                            0, ctx, detail::string_literal<Char, ':', ' '>{}});
      ++i;
    }
    basic_string_view<Char> close = detail::string_literal<Char, '}'>{};
    if (!no_delimiters_) out = detail::copy<Char>(close, out);
    return out;
  }
};

// A (debug_)string formatter.
template <typename R, typename Char>
struct formatter<
    R, Char,
    enable_if_t<range_format_kind<R, Char>::value == range_format::string ||
                range_format_kind<R, Char>::value ==
                    range_format::debug_string>> {
 private:
  using range_type = detail::maybe_const_range<R>;
#ifdef __cpp_lib_ranges
  using string_type = conditional_t<
      std::is_constructible_v<std::basic_string_view<Char>,
                              std::ranges::iterator_t<range_type>,
                              std::ranges::sentinel_t<range_type>>,
      std::basic_string_view<Char>, std::basic_string<Char>>;
#else
  using string_type = std::basic_string<Char>;
#endif

  formatter<string_type, Char> underlying_;

 public:
  template <typename ParseContext>
  FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
    return underlying_.parse(ctx);
  }

  template <typename FormatContext>
  auto format(range_type& range, FormatContext& ctx) const
      -> decltype(ctx.out()) {
    auto out = ctx.out();
    if (detail::const_check(range_format_kind<R, Char>::value ==
                            range_format::debug_string))
      *out++ = '"';
    out = underlying_.format(
        string_type{detail::range_begin(range), detail::range_end(range)}, ctx);