std::reference_wrapper<T> is a standard library type that mimics built-in references as much as possible, while allowing the reference to be rebound (something built-in references do not allow). This allows one to create containers of std::reference_wrapper<T>, among other things.

A while ago a guy I know was working on a program that involved a large number of “jobs” read from a file/database. The issue he had was that he wanted different “views” of those jobs – for example, he wanted a view of the jobs sorted by job ID, another of the jobs sorted by start/end time, another sorted by priority, and so on. Continue Reading