From Jason Turner
Watch on YouTube

Summary

This episode introduces a seemingly small but important new feature in C++23: the auto{} and auto() syntax for creating explicit copies of objects. Jason explains the motivation behind this feature using a practical example where passing a container's front element by reference to std::erase can lead to unpredictable behavior when the referenced element gets moved during the algorithm's execution. The new syntax provides a clean, built-in way to ensure you're working with a stable copy rather than a potentially changing reference.

Resources

Tags