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

            Bug ID: 100567
           Summary: views::take and views::drop should conditionally use
                    _RangeAdaptor::operator()
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

Hi, the re-implemented range adaptors use _RangeAdaptor to handle the arg of
the adaptors, but for views::take and views::drop, the constraint that this arg
can perfectly forward to range::range_difference_t<V> is lacking.

https://godbolt.org/z/j88q5Yn6Y

#include <ranges>
struct S {
  operator int() { return 0; }
};
const S obj;
auto r  = std::views::iota(0, 3);
auto d1 = r | std::views::drop(obj); // ok, should error
auto d2 = std::views::drop(r, obj);  // error
auto f1 = r | std::views::take(obj); // ok, should error
auto f2 = std::views::take(r, obj);  // error

Reply via email to