Author Topic: C++ Uniform Container Erasure  (Read 2368 times)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
C++ Uniform Container Erasure
« on: November 28, 2019, 04:27:27 PM »
I was watching some programming videos and found this one:
C++20's Uniform Container Erasure

It seems C++ is finally getting an easy way to remove items from containers. For example, to remove all occurrences of a value from a vector:
Code: [Select]
erase(vec, value);

This is in contrast to the older and much more verbose way:
Code: [Select]
vec.erase(std::remove(vec.begin(), vec.end(), value), vec.end());

The paper about it is here:
Uniform Container Erasure

Some documentation can be found at:
C++ standard libraries extensions, version 2

You'll notice the documentation links to specific methods for each of the container types, including std::string which isn't always thought of as a container.