简体   繁体   English

为什么“累积”没有进入 C++20 的范围?

[英]Why didn't `accumulate` make it into Ranges for C++20?

I suspect that accumulate isn't the only algorithm that didn't make it.我怀疑accumulate不是唯一没有成功的算法。

Maybe now there's a better way to perform accumulation (folding) over a range and therefore the accumulate is obsolete?也许现在有一种更好的方法可以在一个范围内执行累加(折叠),因此accumulate已经过时了?

No, accumulate is a perfectly reasonable algorithm, and it's not made obsolete by any other algorithm.不, accumulate是一种完全合理的算法,并且不会被任何其他算法淘汰。 The reason for it not being included in c++20 is simply a matter of time.它没有被包含在 c++20 中的原因只是时间问题。 It was considered better to add as much as possible with regards to ranges, without worrying about adding everything at once.最好尽可能多地添加范围,而不必担心一次添加所有内容 Otherwise, there was a risk that none of the constrained algorithms would have made it to c++20, which would have been a shame.否则,有一个风险,即没有任何约束的算法会去到C ++ 20,这将是一个耻辱。

There are still a few algorithms that haven't been constrained yet, as well as the entirety of the <numeric> , and <memory> headers.还有一些算法尚未受到约束,以及<numeric><memory>标头的全部内容。

Forunately, there is a proposal to add these remaining algorithms (and I'm optimistic that these will be added in c++23).幸运的是,有人提议添加这些剩余的算法(我很乐观地认为这些将在 c++23 中添加)。 In fact, the introduction to this proposal answers your question nicely:事实上,这个提案的介绍很好地回答了你的问题:

“Every time someone asks why we didn't cover <numeric> and <memory> algorithms: We thought 187 pages of TS was enough.” “每次有人问我们为什么没有介绍<numeric><memory>算法时:我们认为 187 页的 TS 就足够了。” — Casey Carter — 凯西·卡特

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM