C++ 23 · Containers and algorithms

Remove matching elements

Erase every element that satisfies a condition (C++20).

std::erase_if(v, [](int n) { return n % 2 == 0; });

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?