I just wrote a small helper function as a wrapper of std::accumulate
:
template <typename FwdIter> inline
auto accumulate(FwdIter begin, FwdIter end) -> std::iterator_traits<FwdIter>::value_type
{
return std::accumulate(begin, end, std::iterator_traits<FwdIter>::value_type());
}
I'm probably overlooking something here. Why isn't this an existing overload of std::accumulate
? The function appears so obvious that it can't have been overlooked; someone had a good reason to make that third parameter mandatory.
(See also Understanding std::accumulate - I understand why you want the ability to provide an initial value, I just don't understand why it is mandatory)