VOOZH about

URL: https://www.geeksforgeeks.org/cpp/reference_wrapper-in-cpp/

⇱ reference_wrapper in C++ - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

reference_wrapper in C++

Last Updated : 3 Dec, 2019
std::reference_wrapper is a class template that wraps a reference in a copy constructible and copy assignable object or reference to function of type T. Instances of std::reference_wrapper are objects (they can be copied or stored in containers) but they are implicitly convertible to ‘T&’ so that they can be used as arguments with the functions that take the underlying type by reference. Syntax:
template <class T> class reference_wrapper;
template parameter(T): type of the referred element and
 this can be either function or object.
Example: Output:
geeks
Comment
Article Tags: