为什么`accumulate`不能进入C ++ 20的范围? [英] Why didn't `accumulate` make it into Ranges for C++20?

查看:64
本文介绍了为什么`accumulate`不能进入C ++ 20的范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怀疑 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:

每次有人问为什么我们不介绍< numeric> < memory> 算法时,我们认为187页的TS就足够了."—凯西·卡特

"Every time someone asks why we didn’t cover <numeric> and <memory> algorithms: We thought 187 pages of TS was enough." — Casey Carter

这篇关于为什么`accumulate`不能进入C ++ 20的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆