reference_wrapper in C++ Last Updated : 03 Dec, 2019 Comments Improve Suggest changes 2 Likes Like Report 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: CPP // C++ program to demonstrate the // use of std::reference_wrapper #include <iostream> #include <functional> using namespace std; int main () { char a = 'g', b = 'e', c = 'e', d = 'k', e = 's'; // creating an array of character "references": reference_wrapper<char> ref[] = {a, b, c, d, e}; for (char& s : ref) cout << s; return 0; } Output: geeks Create Quiz Comment R rajasethupathi Follow 2 Improve R rajasethupathi Follow 2 Improve Article Tags : Misc C++ CPP-Library cpp-references Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like