-
-
Save fabiogaluppo/9ba7c3fe101ab0beeb0b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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