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

            Bug ID: 109474
           Summary: chunk_by doesn't work for ranges of proxy references
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Reduced example from Conor's tweet
(https://twitter.com/code_report/status/1645831980473282560):

#include <vector>
#include <ranges>

void f(std::vector<bool> v) {
    auto z = std::views::chunk_by(
        v,
        [](auto&& lhs, auto&& rhs){
            return true;
        });
    auto i = z.begin();
}

This fails because the find_next implementation right now
(https://github.com/gcc-mirror/gcc/blob/0c5e64c4249322a178e1a0e843874e4d6b43b992/libstdc%2B%2B-v3/include/std/ranges#L6741-L6750)
passes a predicate into adjacent_find that requires both parameters be the same
type, but in this case indirect_binary_predicate is checking that it's
invocable with both value_type& (bool&) and reference
(vector<bool>::reference), which in this case are different types.

The original example was a zip_view of two ranges - which likewise would have
value_type& and reference be different.

Reply via email to