https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100795

--- Comment #7 from 康桓瑋 <hewillk at gmail dot com> ---
(In reply to Patrick Palka from comment #6)
> (In reply to 康桓瑋 from comment #2)
> > ranges::inplace_merge has the same issue:
> > 
> > 
> > #include <algorithm>
> > #include <array>
> > #include <ranges>
> > 
> > int main() {
> >   std::array a{42, 42, 42};
> >   auto r = std::views::iota(0, 3) | 
> >            std::views::transform([&a](int i) -> int& { return a[i]; });
> >   std::ranges::inplace_merge(r, r.begin());
> > }
> > 
> > https://godbolt.org/z/q6jbxGMjd
> 
> Hmm, this one seems more like a problem in the specification of
> transform_view::iterator_category.  Shouldn't r's iterator_category be
> random_access_iterator here?  AFAICT it satisfies all the requirements of
> __LegacyRandomAccessIterator.

Damn, I think you are right. According to [range.transform.iterator#2.1], even
if is_lvalue_reference_v<invoke_result_t<F&, range_reference_t<Base>>> is true,
transform_view::iterator_category is still determined by the
iota_view::iterator_category.

Reply via email to