Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

multimap empty() function in C++ STL

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The multimap::empty() is a boolean type observer function in C++ STL which tells whether the container is empty or not. This function returns true when the multimap container is empty (i.e. the size of the container is 0). Being an observer function it does not modify the multimap in any way. Syntax:


Return Value: This method returns a boolean type value. It returns true when multimap is empty else returns false. Below program illustrate the multimap::empty() function: 


// C++ program to demonstrate
// std::multimap::empty
#include <iostream>
#include <map>
using namespace std;
int main()
    // declaring multimap
    multimap<char, int> mmap;
    // checking if mmap is empty or not
    if (mmap.empty())
        cout << "multimap is empty\n";
    // inserting values to mmap
    // thus making it non empty
    mmap.insert(pair<char, int>('a', 26));
    mmap.insert(pair<char, int>('b', 30));
    mmap.insert(pair<char, int>('c', 44));
    // checking that mmap is now not empty
    if (mmap.empty())
        cout << "multimap is empty\n";
        cout << "multimap is not empty\n";
    return 0;


multimap is empty
multimap is not empty

Time Complexity : O(1)

My Personal Notes arrow_drop_up
Last Updated : 22 Jun, 2022
Like Article
Save Article
Similar Reads
Related Tutorials