Skip to content

Instantly share code, notes, and snippets.

@jaguilar
Last active August 29, 2015 14:09
Show Gist options
  • Save jaguilar/f7e51a5b3f89b18fb54a to your computer and use it in GitHub Desktop.
Save jaguilar/f7e51a5b3f89b18fb54a to your computer and use it in GitHub Desktop.
c_transform
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