Skip to content

Instantly share code, notes, and snippets.

@hsiuhsiu
Last active October 5, 2021 04:54
Show Gist options
  • Save hsiuhsiu/d63cd0c0d05dcaabd71f1dec1759226e to your computer and use it in GitHub Desktop.
Save hsiuhsiu/d63cd0c0d05dcaabd71f1dec1759226e to your computer and use it in GitHub Desktop.
Remove elements in a vector #cpp
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