Skip to content

Instantly share code, notes, and snippets.

@fabiogaluppo
Last active October 13, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiogaluppo/ac658eea198740af7d20 to your computer and use it in GitHub Desktop.
Save fabiogaluppo/ac658eea198740af7d20 to your computer and use it in GitHub Desktop.
std::copy_if sample
std::vector<int> xs = { 1, 2, 3, 4, 5, 6, 7, 8 }, ys;
ys.resize(xs.size() / 2);
auto is_odd = [](int i) {
return (i & 0x1) == 0x1;
};
std::copy_if(xs.begin(), xs.end(), ys.begin(), is_odd); //ys = 1, 3, 5, 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment