std::ref and std::reference_wrapper: Common use cases -- Hitesh Kumar

Save to:
Instapaper Pocket Readability

fbgohNwY5aexuWMq9qJ95DEN.jpgMotivation behind reference_wrapper and common use cases.

std::ref and std::reference_wrapper: Common use cases

by Hitesh Kumar

From this article:

An std::reference_wrapper is a copyable and assignable object that emulates a reference. Contrary to its name, it does not wrap a reference. It works by encapsulating a pointer (T*) and by implicitly converting to a reference (T&). It cannot be default constructed or initialized with a temporary; therefore, it cannot be null or invalid.

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.