Skip to content

cartesian_product doesn't work with filter_view #978

@brevzin

Description

@brevzin

Reduced from StackOverflow:

#include <range/v3/view/cartesian_product.hpp>
#include <range/v3/view/filter.hpp>

int main() {
    int data[] = {1};
    ranges::view::cartesian_product(
        data | ranges::view::filter([](int){ return true; }),
        data);
}

fails with a huge error, the top of which is:

In file included from /opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/view/cartesian_product.hpp:21,
                 from <source>:1:
/opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/range_concepts.hpp: In instantiation of 'class ranges::v3::cartesian_product_view<ranges::v3::remove_if_view<ranges::v3::iterator_range<int*, int*>, ranges::v3::logical_negate_<main()::<lambda(int)> > >, ranges::v3::iterator_range<int*, int*> >':
<source>:8:17:   required from here
/opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/range_concepts.hpp:78:50: error: no match for call to '(const ranges::v3::_begin_::fn) (const ranges::v3::remove_if_view<ranges::v3::iterator_range<int*, int*>, ranges::v3::logical_negate_<main()::<lambda(int)> > >&)'
   78 |                 using iterator_t = decltype(begin(std::declval<T &>()));
      |                                             ~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/view/cartesian_product.hpp:19,
                 from <source>:1:
/opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/begin_end.hpp:88:32: note: candidate: 'template<class R> constexpr decltype (ranges::v3::_begin_::fn::impl_(r, 42)) ranges::v3::_begin_::fn::operator()(R&) const'
   88 |                 constexpr auto operator()(R &r) const
      |                                ^~~~~~~~

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions