[英]Why has std::accumulate not been made constexpr in C++20?
在 C++20 中,许多(大多数?)C++ 标准库算法已被制作为constexpr
。 然而 - std::accumulate
没有。
似乎它可能是:
template<class InputIt, class T>
constexpr T accumulate(InputIt first, InputIt last, T init)
{
for (; first != last; ++first) {
init = std::move(init) + *first;
}
return init;
}
那么 - 是否有原因它也不是constexpr
?
有一个提案正在处理中。 在这个过程完成之前我们不会知道结果,但它不会生成 C++20。
确实有一个提案: constexpr for algorithms ,引用相关部分:
本提案是在以下 function 模板中添加 constexpr,但接受 ExecutionPolicy 的 function 模板除外。
- 积累
...
我们可以从cplusplus/papers 的第 432 期看到,该论文被转移到了 Language Evolution 工作组:
R0,需要LEWG查看/转发。 移除 LWG 标签。
里程碑移至2019-11
:
修改里程碑:2019-07、2019-11
这将是即将举行的贝尔法斯特会议,因此它不会使 C++20 成为可能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.