From Jason Turner
Watch on YouTube

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.

Resources

Tags