Understanding std::accumulate
问题 I want to know why std::accumulate (aka reduce) 3rd parameter is needed. For those who do not know what accumulate is, it's used like so: vector<int> V{1,2,3}; int sum = accumulate(V.begin(), V.end(), 0); // sum == 6 Call to accumulate is equivalent to: sum = 0; // 0 - value of 3rd param for (auto x : V) sum += x; There is also optional 4th parameter, which allow to replace addition with any other operation. Rationale that I've heard is that if you need let say not to add up, but multiply