Use a simple loop instead of a std::accumulate with a custom function. I do not see how std::accumulate can be any faster, this makes code more readable.