Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
template<typename InputIterator>
inline typename InputIterator::value_type sum(InputIterator first, InputIterator last)
{
typename InputIterator::value_type init{};
return std::accumulate(first, last, init);
}
template<typename Container>
inline typename Container::value_type sum(const Container& cont)
{
typename Container::value_type init{};
return std::accumulate(std::begin(cont), std::end(cont), init);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment