unordered_multiset get_allocator in C++ STL

The unordered_multiset::get_allocator() function is a STL function in C++ which is used to include unorder_multiset header file in program. This function gets the stored allocator object and returns the allocator object which is used to construct the container. It is a public member function.


allocator_type get_allocator() const;

Here allocator_type is the type of the allocator which is used by the container.

Parameters: It does not accepts any parameter.

Return Value: It returns the allocator type.

Below program illustrate get_allocator method in C++ STL:






// c++ program to understand 'unordered_multiset_get_allocator'
#include <iostream>
#include <unordered_set>
using namespace std;
// main() method
int main() 
    //'m' is object of 'unordered_set'
    unordered_multiset<int> m;
    //'allocator_type' is inherit in 'unordered_multiset'
    //'t' is object of 'allocator_type'
    //'get_allocator()' is member of 'unordered_set'
    unordered_multiset<int>::allocator_type t = m.get_allocator();
    // Comparing the Allocator with 'Pair<int, int>'
    cout << "allocator is : "
        << boolalpha << (t == allocator<std::pair<int, int> >());
    return (0);



allocator is : true

Complexity: It takes constant time of complexity to perform operation.

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.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to 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.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.