Browse DevX
Sign up for e-mail newsletters from DevX


Solve the Forwarding Problem and Simulate Containers of References

Have you been beaten by the argument forwarding bug? Are you frustrated by the inability to create containers of references in C++98? Find out how the reference wrapper mini-library cures these ailments.

R1 recently enhanced the standard header <utility> with a small reference wrapping library that includes the class template reference_wrapper and the helper functions ref() and cref(). This mini-library library solves the onerous problem of argument forwarding. In addition, it enables you to simulate containers of references. The following sections explain how to do that.

How do you pass references as arguments to algorithms? How do you create containers of references?

Use reference_wrapper and its associated helper functions ref() and cref().

Thanks for your registration, follow us on our social networks to keep up-to-date