For any C++ programmers...
When using 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 static_cast<uint64_t>(0)
instead.)