unordered_map get_allocator in C++ STL Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report unordered_map::get_allocator() is a built in function in C++ STL which is used to get allocator of container unordered_map. Syntax Allocator_type get_allocator() Parameters: This function does not accept any parameter. Return value: Returns an allocator associated with unordered_map. Below programs explains clearly the unordered_map::get_allocator() function. Example-1: CPP // CPP program to illustrate // unordered_map get_allocator() #include <bits/stdc++.h> using namespace std; int main() { //'ump' is object of 'unordered_ump' unordered_map<int, int> ump; //'allocator_type' is inherit in 'unordered_map' //'u' is object of 'allocator_type' unordered_map<int, int>::allocator_type u = ump.get_allocator(); // Comparing the Allocator with Pair<int, int> cout << "Is allocator Pair<int, int> : " << boolalpha << (u == allocator<pair<int, int> >()); return 0; } Output: Is allocator Pair : true Example-2: CPP // CPP program to illustrate // unordered_map get_allocator() #include <bits/stdc++.h> using namespace std; int main(void) { unordered_map<char, int> um; pair<const char, int>* a; a = um.get_allocator().allocate(8); cout << "Allocated size = " << sizeof(*a) * 8 << endl; return 0; } Output: Allocated size = 64 Comment More infoAdvertise with us Next Article unordered_map cend in C++ STL A ankit15697 Follow Improve Article Tags : C++ cpp-unordered_map cpp-unordered_map-functions Practice Tags : CPP Similar Reads unordered_multimap get_allocator in C++ STL unordered_multimap::get_allocator() is a built in function in C++ STL which is used to get allocator of container unordered_mulitmap. Syntax: Allocator_type get_allocator() Parameters: This function does not accept any parameter. Return value: Returns an allocator associated with unordered_multimap. 1 min read 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. Syntax 1 min read map get_allocator in C++ STL map::get_allocator() is a built in function in C++ STL which is used to get allocator of container map. Syntax: Allocator_type get_allocator() Parameters: This function does not accept any parameter. Return value: Returns an allocator associated with map. Below programs explains clearly the map::get 1 min read unordered_map cend in C++ STL The unordered_map::cend() is a built-in function in C++ STL which returns an iterator pointing to the position past the end element in the container or in one of its bucket. In an unordered_map object, there is no guarantee that which specific element is considered its first element. But all the ele 3 min read unordered_map empty in C++ STL unordered_map::empty() function is used to check whether container size is zero or not. If container size is zero then it return TRUE otherwise it return FALSE. Syntax: unordered_map_name.empty() Parameters: This function does not accept any parameter Return type: This function returns boolean value 2 min read unordered_map clear in C++ STL unordered_map::clear() function is used to remove all elements from the container. When this function is applied to unordered_map its size becomes zero. Syntax: unordered_map_name.clear() Parameters: This function does not accepts any parameter Return type: This function return nothing. Examples: In 2 min read Like