2 ms·
My mistake; I read about it (http://en.cppreference.com/w/cpp/algorithm/remove http://en.cppreference.com/w/cpp/algorithm/remove) too fast and thought it was th
by smitherfield 10y ago
My mistake; I read about it (http://en.cppreference.com/w/cpp/algorithm/remove http://en.cppreference.com/w/cpp/algorithm/remove) too fast and thought it was the simple inverse of copy. I wasn't aware of it before this thread.
In the unlikely event some future reader is copy-pasting these snippets, here's the corrected version:
const auto last{ std::remove_if(vec.begin(), vec.end(),
[](const auto x) { return x <= 2; }) };
vec.resize(last - vec.cbegin());