reference_wrapper in C++ Last Updated : 03 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article 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 Comment More infoAdvertise with us Next Article Self-Referential Classes in C++ R rajasethupathi Follow Improve Article Tags : Misc C++ CPP-Library cpp-references Practice Tags : CPPMisc Similar Reads is_reference Template in C++ The std::is_reference template of C++ STL is used to check whether the type is a reference type or not. It returns a boolean value showing the same. Syntax: template <class T > struct is_reference; Parameter: This template accepts a single parameter T (Trait class) to check whether T is a refe 2 min read What are Reference Collapsing Rules in C++? In C++, we have a very useful feature called reference collapsing, which comes into play when dealing with references to references, especially in the context of templates. It is very important to make templates work seamlessly with references, ensuring that code behaves consistently and as expected 4 min read Reference to Dynamic Objects in C++ In C++, the objects can be created at run-time. C++ supports two operators new and delete to perform memory allocation and de-allocation. These types of objects are called dynamic objects. The new operator is used to create objects dynamically and the delete operator is used to delete objects dynami 3 min read Self-Referential Classes in C++ A class is a building block in C++ that leads to Object-Oriented programming. It is a user-defined type that holds its own data members and member functions. These can be accessed by creating an instance of the type class. Self-referential classes are a special type of classes created specifically f 3 min read Inheritance in C++ The capability of a class to derive properties and characteristics from another class is called Inheritance. Inheritance is one of the most important features of Object-Oriented Programming in C++. In this article, we will learn about inheritance in C++, its modes and types along with the informatio 10 min read std::add_lvalue_reference in C++ with Examples The std::add_lvalue_reference template of C++ STL is present in the <type_traits> header file. The std::add_lvalue_reference template of C++ STL is used to get lvalue reference type that refers to T type. An lvalue reference is formed by placing an '&' after some type. An rvalue reference 2 min read Like