You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Addresses issue (fmtlib#3802)
For input_ranges (ie. a range with an input iterator backing it) we
should not copy the iterator and should mutate the iterator on the view.
For forward_ranges (or better), we can keep using them as const and make
a copy of the iterator etc.
This is an issue for code like:
std::istringstream iss("1 2 3 4 5");
auto view = std::views::istream<int>(iss)
fmt::join(std::move(view), ", ")
Since the std::ranges::basic_istream_view::__iterator is not copyable
And the struct formatter<join_view<It, Sentinel, Char>, Char>
only has a
template <typename FormatContext>
auto format(const join_view<It, Sentinel, Char>& value,
FormatContext& ctx) const -> decltype(ctx.out()) {
auto it = value.begin;
Which takes the value param by const ref and copies the iterator
Fix is disabling the const ref format function overload when we have an
input iterator passed to our join_view, and instead then just mutate the
iterator in place and use a mutable join_view& overload for this case
0 commit comments