unordered_multimap emplace() function in C++ STL Last Updated : 08 Aug, 2018 Suggest changes Share Like Article Like Report The unordered_multimap::emplace() is a built-in function in C++ STL which inserts a new {key, element} in the unordered_multimap container. The insertion is done automatically at the position according to the container's criterion. It increases the size of the container by one. Syntax: unordered_multimap_name.emplace(key, element) Parameters: The function accepts a single mandatory parameter key and element which is to be inserted in the container. Return Value: It returns an iterator which points to the newly inserted element. Below programs illustrates the above function: Program 1: CPP // C++ program to illustrate // unordered_multimap::emplace() #include <iostream> #include <string> #include <unordered_map> using namespace std; int main() { // declaration unordered_multimap<int, int> sample; // inserts key and elements sample.emplace(1, 2); sample.emplace(1, 2); sample.emplace(1, 3); sample.emplace(4, 9); sample.emplace(60, 89); cout << "Key and Elements: \n"; for (auto it = sample.begin(); it != sample.end(); it++) cout << "{" << it->first << ":" << it->second << "}\n "; return 0; } Output: Key and Elements: {60:89} {4:9} {1:3} {1:2} {1:2} Program 2: CPP // unordered_multimap::emplace #include <iostream> #include <string> #include <unordered_map> using namespace std; int main() { // declaration unordered_multimap<string, string> sample; // inserts key and elements sample.emplace("gopal", "dave"); sample.emplace("gopal", "dave"); sample.emplace("Geeks", "C++"); sample.emplace("multimap", "functions"); sample.emplace("multimap", "functions"); cout << "Key and Elements: \n"; for (auto it = sample.begin(); it != sample.end(); it++) cout << "{" << it->first << ":" << it->second << "}\n "; return 0; } Output: Key and Elements: {multimap:functions} {multimap:functions} {Geeks:C++} {gopal:dave} {gopal:dave} G gopaldave Follow Article Tags : Misc C++ STL CPP-Functions cpp-unordered_multimap +1 More 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 My Profile ${profileImgHtml} My Profile Edit Profile My Courses Join Community Transactions Logout Like