Why has std::accumulate not been made constexpr in C++20?
P1645R1 was actually adopted in the Belfast meeting for inclusion in C++20 in response to NB comment US 320.
As a result, all of the following algorithms will be constexpr
in C++20 (except for the overloads of them that take an ExecutionPolicy
):
- accumulate
- reduce
- inner_product
- transform_reduce
- partial_sum
- exclusive_scan
- inclusive_scan
- transform_exclusive_scan
- transform_inclusive_scan
- adjacent_difference
- iota
TL;DR;
There is a proposal in process. We won't know the result until the process is done but it won't make C++20.
Longer answer
There was indeed a proposal: constexpr for algorithms, quoting the relevant part:
This proposal is to add constexpr to the following function templates in , excepting the function templates that accept an ExecutionPolicy.
- accumulate
...
We can see from the cplusplus/papers issue 432 that the paper was moved to Language Evolution Working Group:
R0, needs to be looked at / forwarded by LEWG. Removing the LWG tag.
and the milestone was moved to 2019-11
:
modified the milestones: 2019-07, 2019-11
which would be the upcomoing Belfast meeting, so it will not make C++20.