The multiset::empty() function is a built-in function in C++ STL which checks if the multiset is empty or not. It returns true if the multiset is empty, else it returns false.
Syntax:
multiset_name.empty()
Parameters: The function does not accepts any parameter.
Return Value: The function returns true if the multiset is empty, else it returns false.
Below programs illustrates the multimap::empty() function:
Program 1:
// CPP program to demonstrate the // multiset::empty() function #include <bits/stdc++.h> using namespace std; int main() { int arr[] = { 15, 10, 15, 11, 10, 18, 18, 20, 20 }; // initializes the set from an array multiset<int> s(arr, arr + 9); if (!s.empty()) cout << "The multiset is not empty"; else cout << "The multiset is empty"; return 0; } |
The multiset is not empty
Program 2:
// CPP program to demonstrate the // multiset::empty() function #include <bits/stdc++.h> using namespace std; int main() { // declaration multiset<int> s; if (!s.empty()) cout << "The multiset is not empty"; else cout << "The multiset is empty"; return 0; } |
The multiset is empty
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- multiset insert() function in C++ STL
- multiset find() function in C++ STL
- multiset equal_range() function in C++ STL
- multiset clear() function in C++ STL
- multiset count() function in C++ STL
- multiset emplace_hint() function in C++ STL
- multiset rbegin() and rend() function in C++ STL
- multiset crbegin() and crend() function in C++ STL
- multiset cbegin() and cend() function in C++ STL
- multiset begin() and end() function in C++ STL
- multiset get_allocator() function in C++ STL
- multiset key_comp() function in C++ STL
- Multiset in C++ Standard Template Library (STL)
- multiset::operator= in C++ STL
- multiset::swap() in C++ STL
- multiset::emplace() in C++ STL
- multiset lower_bound() in C++ STL with Examples
- multiset upper_bound() in C++ STL with Examples
- multiset max_size() in C++ STL with Examples
- multiset size() in C++ STL with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. 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.

