Summary
This episode explores a new feature in C++20 called uniform container erasure that simplifies removing elements from standard containers. Jason demonstrates how the traditional remove-erase idiom (which requires chaining the std::remove algorithm with the container's erase method) can be replaced with the new std::erase and std::erase_if free functions. These new functions work consistently across all standard containers, providing a more concise and readable solution while eliminating container-specific implementation details. The feature has already been implemented in GCC and Clang standard libraries.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[diff.cpp20.containers]67% match -
[diff.cpp17.containers]64% match -
[diff.cpp03.containers]62% match -
[diff.cpp14.containers]61% match -
[diff.cpp23.containers]60% match -
[string.erase]60% match -
[diff.cpp03.algorithms]60% match -
[new.delete]59% match -
[new.delete.general]58% match -
[new.delete.placement]58% match - + 3 more related sections