Forward list in STL implements singly linked list. Introduced from C++11, forward lists are useful than other containers for insertion, removal and moving operations (like sort) and allows time constant insertion and removal of elements.It differs from the list by the fact that forward list keeps track of the location of only next element while list keeps track to both next and previous elements.
This operator is used to assign new contents to the container by replacing the existing contents.
It also modifies the size according to the new contents.
forwardlistname1 = (forwardlistname2) Parameters : Another container of the same type. Result : Assign the contents of the container passed as the parameter to the container written on left side of the operator.
Input : myflist1 = 1, 2, 3 myflist2 = 3, 2, 1, 4 myflist1 = myflist2; Output : myflist1 = 3, 2, 1, 4 Input : myflist1 = 2, 6, 1, 5 myflist2 = 3, 2 myflist1 = myflist2; Output : myflist1 = 3, 2
Errors and Exceptions
1. If the containers are of different types, an error is thrown.
2. It has a basic no exception throw guarantee otherwise.
myflist1 = 3 2 1 4
- C++ Program to concatenate two strings using Operator Overloading
- Is there any equivalent to typedef of C/C++ in Java ?
- Count elements in a vector that match a target value or condition
- Swapping of subranges from different containers in C++
- Get first and last elements from Array and Vector in CPP
- Interesting Facts about C++
- Types of Operator Overloading in C++
- C++ Program to count Vowels in a string using Pointer
- C++ Program to swap two members using Friend Function
- is_empty template in C++
- is_standard_layout template in C++
- Program to Print Mirrored Hollow Parallelogram
- MakeFile in C++ and its applications
- Internal details of std::sort() in C++
- multiset erase() 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.