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吗?