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

            Bug ID: 108291
           Summary: chunk_­by_­view::find-next/find-prev uses wrong lambda
                    helper
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hewillk at gmail dot com
  Target Milestone: ---

constexpr iterator_t<_Vp>
    _M_find_next(iterator_t<_Vp> __current)
    {
      __glibcxx_assert(_M_pred.has_value());
      auto __pred = [this]<typename _Tp>(_Tp&& __x, _Tp&& __y) {
        return !bool((*_M_pred)(std::forward<_Tp>(__x),
std::forward<_Tp>(__y)));
      };
      auto __it = ranges::adjacent_find(__current, ranges::end(_M_base),
__pred);
      return ranges::next(__it, 1, ranges::end(_M_base));
    }

This template lambda assumes that both parameters should have the same type,
which will affect the constraint check, it should be

    auto __pred = [this]<typename _Tp, typename _Up>(_Tp&& __x, _Up&& __y) {
      return !bool((*_M_pred)(std::forward<_Tp>(__x), std::forward<_Up>(__y)));
    };


testcase:

    #include <ranges>

    int main() {
      std::string_view s = "hello";
      auto r = s | std::views::chunk_by(std::less{});
      ++r.begin();
    }

https://godbolt.org/z/rcfqqcG66

Reply via email to