For any C++ programmers...
std::accumulate, the return type is inferred based on the third parameter. So be sure that the third argument is the same type you expect it to return. See this example.
(For some reason codepad’s C++ compiler complained about using
0ULL, so I used