Last active
October 5, 2021 04:54
-
-
Save hsiuhsiu/d63cd0c0d05dcaabd71f1dec1759226e to your computer and use it in GitHub Desktop.
Remove elements in a vector #cpp
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
auto p = std::remove_if( | |
std::begin(a), std::end(a), [](const auto& e) { return e.seleted(); }); | |
a.erase(p, std::end(a)) | |
// in C++20 | |
auto p = ranges::remove_if(a, &E::selected); | |
a.erase(p, std::end(a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment