Created
May 13, 2018 12:47
-
-
Save saschagrunert/1c7d2481a289eb90fb58998e66d8e489 to your computer and use it in GitHub Desktop.
This file contains 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 <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