From Jason Turner
Watch on YouTube

Summary

This episode highlights two useful but often overlooked functions in the C++ standard library: std::next and std::exchange. Jason demonstrates how std::next provides a standard way to safely advance any type of iterator, even for container types that don't support random access iteration, avoiding common manual workarounds. He then explores std::exchange, which enables replacing a value while simultaneously retrieving the previous value in one operation, making code both more concise and potentially more efficient by leveraging move semantics.

Resources

Tags