accumulate does not work with iterator?

Hi,

I have the following code
1
2
3
4
5
	array<int, 5> a = {1, 3, 5, 7, 9};
	int tage = 0;

	auto it = a.begin();
	accumulate(it, it+3, tage);

However, I does not work. The value of tage is not changed. Could anyone please tell me why? Thanks!
Why do you expect the value of tage to be changed?

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <array>
#include <numeric>
#include <iostream>
int main()
{
    std::array<int, 5> a = {1, 3, 5, 7, 9};
    int tage = 0;

    auto it = a.begin();
    int sum = std::accumulate(it, it+3, tage);

    std::cout << sum << '\n';
}

demo: http://ideone.com/yp0wg0
Thanks!
Topic archived. No new replies allowed.