The ‘=’ is an operator in C++ STL which copies (or moves) an unordered_map to another unordered_map and unordered_map::operator= is the corresponding operator function. There are three versions of this function.
- The first version takes reference of an unordered_map as an argument and copies it to an unordered_map.
- The second version performs a move assignment i.e it moves the content of an unordered_map to another unordered_map.
- The third version assigns contents of an initializer list to an unordered_map.
ump.operator= ( unordered_map& ump ) ump.operator= ( unordered_map&& ump ) ump.operator= ( initializer list )
- The first version takes the reference of an unordered_map as argument.
- The second version takes the r-value reference of an unordered_map as argument.
- The third version takes an initializer list as argument.
Return value: All of them returns the value of this pointer(*this).
Below program illustrates the unordered_map::operator= in C++.
7 : 8 9 : 10 11 : 12 1 : 2 3 : 4 5 : 6 11 : 12 9 : 10 7 : 8 7 : 8 9 : 10 11 : 12 1 : 2 3 : 4 5 : 6
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Operator Overloading '<<' and '>>' operator in a linked list class
- dot (.) operator in C/C++
- map operator= in C++ STL
- set operator= in C++ STL
- map::operator in C++ STL
- new vs operator new in C++
- unordered_set operator= in C++ STL
- multiset::operator= in C++ STL
- match_results operator in C++ STL
- match_results operator= in C++
- multimap::operator= in C++ STL
- list::operator= in C++ STL
- vector::operator= and vector::operator[ ] in C++ STL
- array::operator[ ] in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.