Skip to content

Instantly share code, notes, and snippets.

@saschagrunert
Created May 13, 2018 12:47
Show Gist options
  • Save saschagrunert/1c7d2481a289eb90fb58998e66d8e489 to your computer and use it in GitHub Desktop.
Save saschagrunert/1c7d2481a289eb90fb58998e66d8e489 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
// Create a vector
std::vector<uint32_t> v = {1, 2, 3, 4, 5};
// Filter by erase-remove
v.erase(std::remove_if(v.begin(),
v.end(),
[&](const uint32_t v) {
return v < 4;
}),
v.end());
// Outputs to:
// 4
// 5
for (const auto & r : v) {
std::cout << r << '\n';
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment