unordered_multimap max_size() function in C++ STL Last Updated : 20 Aug, 2018 Suggest changes Share Like Article Like Report The unordered_multimap::max_size() is a built-in function in C++ STL which returns the maximum number of elements that the unordered_multimap container can hold. Syntax: unordered_multimap_name.max_size() Parameters: The function does not accepts any parameters. Return Value: It returns an integral values which denotes the maximum size of elements that the container can hold. Below programs illustrates the above function: Program 1: CPP // C++ program to illustrate the // unordered_multimap::max_size() #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multimap<int, int> sample1; // inserts key and element // in sample1 sample1.insert({ 10, 100 }); sample1.insert({ 50, 500 }); cout << "The max number of elements that sample1 can hold: " << sample1.size(); cout << "\nKey and Elements of Sample1 are:"; for (auto it = sample1.begin(); it != sample1.end(); it++) { cout << "{" << it->first << ", " << it->second << "} "; } return 0; } Output: The max number of elements that sample1 can hold: 2 Key and Elements of Sample1 are:{50, 500} {10, 100} Program 2: CPP // C++ program to illustrate the // unordered_multimap::max_size() #include <bits/stdc++.h> using namespace std; int main() { // declaration unordered_multimap<char, char> sample1, sample2; // inserts key and element // in sample1 sample1.insert({ 'a', 'A' }); sample1.insert({ 'g', 'G' }); cout << "The max number of elements that sample1 can hold: " << sample1.size(); cout << "\nKey and Elements of Sample1 are:"; for (auto it = sample1.begin(); it != sample1.end(); it++) { cout << "{" << it->first << ", " << it->second << "} "; } return 0; } Output: The max number of elements that sample1 can hold: 2 Key and Elements of Sample1 are:{g, G} {a, A} 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