我们不能在 view::chunk 之前懒惰地做 view::filter 吗?

Can't we lazily do view::filter before view::chunk?

这不会编译:

auto out = view::closed_iota(1,100)
                | view::filter([](auto item){ return item % 10; })
                | view::chunk(10);

for (auto&& rng : out) {
    std::cout << rng << "\n";
}

错误:

In file included from <source>:4:
/opt/compiler-explorer/libs/rangesv3/trunk/include/range/v3/view/chunk.hpp:144:36: error: no matching function for call to object of type 'const _end_::fn'
                return adaptor{n_, ranges::end(this->base())};
                                   ^~~~~~~~~~~

godbolt.org/g/PhcdGc


我想知道这种行为背后的概念是什么?

如果这不满足像 this 这样的概念,为什么没有显示警报?

这看起来像是 chunk 视图中的错误。它期望它的基本范围是 const-iterable,但 filter 视图不是。我会修好它。感谢举报!

编辑:这一个错误。它现在已被 the brilliant and insightful Casey's PR 808.

修复在 master 上