Thanks guys! sum() was the most basic function that I'm doing. I wanted to do mean, median, mode, standard deviation, min, max, variance, correlations, entropy and skewness.
I checked out the possible implementation of std::accumulate from here: http://cplusplus.com/reference/numeric/accumulate/
And it makes sense! What I was missing was template type for the init value. Of course, I'd rather not make people specify initial values just for the type, so std::iterator_traits looks nifty.