std::accumulate
and std::reduce
does almost the same thing.
Summary of of std::reduce
says it all:
similar to `std::accumulate`, except out of order
In many cases these functions should yield the same end result and exhibit the same overall functionality. It is obvious that if you have some very heavy load computation, etc. you can experiment with std::reduce
for parrelization. Ie. what is the conventional wisdom here from a birds view - should you always stick to the blunt std::accumulate unless explicitly optimizating ? or should just default to use std::reduce
?
If std::reduce
(with default/no execution policy chosen) is always at least as fast as std::accumulate
(save a few instructions) then I think accumulate should only be used when the order is strict.