为什么C ++ 20中没有将std :: accumulate设为constexpr?

ein*_*ica 19 c++ c++-standard-library accumulate 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;
}
Run Code Online (Sandbox Code Playgroud)

所以-是否也没有理由constexpr吗?

注意:这个问题是由动机我的回答这个问题的编译时间的积累。

Bar*_*rry 8

P1645R1实际上在贝尔法斯特会议上被采纳并包含在 C++20 中,以响应 NB 评论US 320

因此,以下所有算法都将使用constexprC++20(除了它们的重载使用ExecutionPolicy):

  • 积累
  • 降低
  • 内部产品
  • 变换减少
  • 部分总和
  • 独占_扫描
  • inclusive_scan
  • transform_exclusive_scan
  • transform_inclusive_scan
  • 相邻_差异
  • 物联网