Created
February 16, 2021 15:41
-
-
Save scolton99/5a60b504d7b0fb45aa80bc1549a47675 to your computer and use it in GitHub Desktop.
C++ Vector Map
This file contains hidden or 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
#include <functional> | |
#include <iterator> | |
#include <vector> | |
#include <iostream> | |
namespace std { | |
template<typename S, typename E> | |
vector<E> vector_map(typename std::vector<S>::iterator start, typename std::vector<S>::iterator end, std::function<E(S)> lambda) { | |
vector<E> ret; | |
do { | |
ret.push_back(lambda(*start)); | |
++start; | |
} while (start != end); | |
return ret; | |
} | |
} |
Author
scolton99
commented
Feb 16, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment