Skip to content

Instantly share code, notes, and snippets.

@fabiogaluppo
Last active December 8, 2015 11:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiogaluppo/9ba7c3fe101ab0beeb0b to your computer and use it in GitHub Desktop.
Save fabiogaluppo/9ba7c3fe101ab0beeb0b to your computer and use it in GitHub Desktop.
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