std::ref and std::cref

In the last lesson, we were introduced to reference wrappers. Now, we will learn how to create them.

With the helper functions std::ref and std::cref you can easily create reference wrappers to variables. std::ref will create a non constant reference wrapper, std::cref a constant one:

Get hands-on with 1000+ tech skills courses.