map get_allocator in C++ STL Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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_allocator() function. Example-1: CPP // CPP program to illustrate // map get_allocator() #include <bits/stdc++.h> using namespace std; int main() { //'mp' is object of 'map' map<int, int> mp; //'allocator_type' is inherit in 'map' //'m' is object of 'allocator_type' map<int, int>::allocator_type m = mp.get_allocator(); // Comparing the Allocator with Pair<int, int> cout << "Is allocator Pair<int, int> : " << boolalpha << (m == allocator<pair<int, int> >()); return 0; } Output: Is allocator Pair : true Example-2: CPP // CPP program to illustrate // map get_allocator() #include <bits/stdc++.h> using namespace std; int main(void) { map<char, int> m; pair<const char, int>* a; a = m.get_allocator().allocate(8); cout << "Allocated size = " << sizeof(*a) * 8 << endl; return 0; } Output: Allocated size = 64 Comment More infoAdvertise with us Next Article get_allocator() in C++ A ankit15697 Follow Improve Article Tags : C++ cpp-map cpp-map-functions Practice Tags : CPP Similar Reads set get_allocator() in C++ STL The set::get_allocator() in C++ STL is an in-built function which returns the copy of the allocator object associated with the set. Syntax: mulset.get_allocator(); Parameters: This function does not accept any parameters. Return Value: This function returns the allocator associated with the set. Tim 2 min read list get_allocator in C++ STL list::get_allocator() is an inbuilt in function in C++ STL which is used to get allocator of container list. Syntax: Allocator_type get_allocator() Parameters: This function does not except any parameter. Return value: Returns an allocator associated with list. Below programs explains clearly the li 2 min read unordered_map get_allocator in C++ STL 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 1 min read get_allocator() in C++ In STL, containers can change size dynamically. Allocator is an object that is responsible for dynamic memory allocation/deallocation. get_allocator() is used to allocate memory chunks of memory. It returns a copy of the allocator object associated with the container. It is defined in vector, map, l 4 min read deque get_allocator in C++ STL deque::get_allocator() is a built in function in C++ STL which is used to get allocator of container deque. Syntax: Allocator_type get_allocator() Parameters: This function does not accept any parameter. Return value: Returns an allocator associated with deque. Below programs illustrate the working 2 min read multimap get_allocator() function in C++ STL The multimap::get_allocator() is a function in STL in C++ that returns the copy of allocator object associated with this multimap. Syntax: multimap.get_allocator() Return value: This function returns the copy of the allocator object associated with this multimap. Below example illustrate the get_all 2 min read Like