Last active
August 29, 2015 14:09
-
-
Save jaguilar/f7e51a5b3f89b18fb54a to your computer and use it in GitHub Desktop.
c_transform
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
template <template <typename ...> class Container, | |
typename F, | |
typename InType, | |
typename OutType = | |
typename std::result_of<F(InType)>::type> | |
Container<OutType> c_transform(const Container<InType>& in, | |
const F& f) { | |
Container<OutType> out; | |
auto it = std::inserter(out, out.end()); | |
for (const auto& e : in) { | |
*it = f(e); | |
} | |
return std::move(out); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment