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 T, typename BinaryOp> | |
T accumulate( | |
typename std::vector<T>::const_iterator first, | |
typename std::vector<T>::const_iterator last, | |
T init, | |
BinaryOp op) | |
{ | |
for (;first != last; ++first) | |
init = op(init, *first); | |
return init; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment