Last active
August 29, 2015 14:10
-
-
Save zheplusplus/f52a3d2b2174e1420149 to your computer and use it in GitHub Desktop.
C++0x for_each with index
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 Iterator, typename Function> | |
Function for_each_i(Iterator begin, Iterator end, Function f) | |
{ | |
typedef decltype(*begin) value_type; | |
int i = 0; | |
return std::move(std::for_each(begin, end, [&](value_type& e) {f(i++, e);})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment