问题描述
我怀疑 accumulate
并不是唯一没有实现的算法.
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
是一个非常合理的算法,并且没有其他算法使它过时.不包含在c ++ 20中的原因只是时间问题.最好尽可能增加范围,而不必担心立即添加所有内容.否则,存在没有受限算法可能会使其陷入c ++ 20的风险,这简直是可耻的.
No, accumulate
is a perfectly reasonable algorithm, and it's not made obsolete by any other algorithm. The reason for it not being included in c++20 is simply a matter of time. 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.
还有一些尚未被约束的算法,以及整个< numeric>
和< memory>
标头.
There are still a few algorithms that haven't been constrained yet, as well as the entirety of the <numeric>
, and <memory>
headers.
幸运的是,有一个提案添加其余的算法(我很乐观地将在c ++ 23中添加这些算法).实际上,该提案的简介很好地回答了您的问题:
Forunately, there is a proposal to add these remaining algorithms (and I'm optimistic that these will be added in c++23). In fact, the introduction to this proposal answers your question nicely:
这篇关于为什么`accumulate`不能进入C ++ 20的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!