gpt4 book ai didi

c++ - 我们不能在 view::chunk 之前懒惰地执行 view::filter 吗?

转载 作者:搜寻专家 更新时间:2023-10-31 00:53:18 25 4
gpt4 key购买 nike

这不会编译:

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 View 中的错误。它期望它的基本范围是 const 可迭代的,但 filter View 不是。我会修好它。感谢举报!

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

关于c++ - 我们不能在 view::chunk 之前懒惰地执行 view::filter 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49210190/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com