From Jason Turner
Watch on YouTube

Summary

In this episode, Jason explores std::ref and std::cref, useful utilities for creating reference wrappers. He demonstrates three key use cases: with std::bind to prevent parameter copying, as class members to hold references while maintaining move/copy semantics, and with standard algorithms that take callable objects by value. The const version, std::cref, provides the same functionality but creates a const reference wrapper, preventing modification of the referenced object.

Resources

Tags