The list::emplace() is a built-in function in C++ STL which extends list by inserting new element at a given position.
Parameters: The function accepts two mandatory parameters which are described below:
- position – it specifies the iterator which points to the position in the list where the new element is to be inserted.
- args – it specifies the elements to be inserted in the list container.
Return value: It returns a random access iterator which points to the newly inserted element.
Below programs illustrate the above function:
List: 1 2 5 6 7 8 9 10
List: (3, b) (4, a)
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
- unordered_multimap emplace() function in C++ STL
- vector emplace() function in C++ STL
- unordered_set emplace() function in C++ STL
- unordered_multiset emplace() function in C++ STL
- map emplace() in C++ STL
- set::emplace() in C++ STL
- queue::emplace() in C++ STL
- multimap::emplace() in C++ STL
- unordered_map emplace() in C++ STL
- multiset::emplace() in C++ STL
- emplace vs insert in C++ STL
- stack emplace() in C++ STL
- priority_queue emplace() in C++ STL
- deque emplace in C++ STL
- Inserting elements in std::map (insert, emplace and operator )
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.