std::ref
In C++, `std::ref` is a utility function that creates a reference wrapper for an object. This allows you to pass objects by reference to functions or algorithms that expect to receive values instead. By using `std::ref`, you can avoid unnecessary copies of large objects, improving performance and memory usage.
When you use `std::ref`, it wraps the original object in a way that maintains its reference semantics. This is particularly useful in scenarios involving standard library components like std::thread or std::bind, where you want to ensure that the original object is modified rather than a copy.