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_allocator() method:
Example:
// C++ program demonstrate // multimap::get_allocator() #include <iostream> #include <map> using namespace std; int main() { int psize; multimap<char, int> mm; pair<const char, int>* p; // allocate an array of 5 elements // using mm's allocator: p = mm.get_allocator().allocate(5); // assign some values to array psize = sizeof(multimap<char, int>::value_type) * 5; cout << "The size of allocated array is " << psize << " bytes.\n"; mm.get_allocator().deallocate(p, 5); return 0; } |
chevron_right
filter_none
Output:
The size of allocated array is 40 bytes.
Example 2:
// C++ program to demonstrate // multimap::get_allocator() #include <iostream> #include <map> using namespace std; int main() { int psize; multimap<char, int> mm; pair<const char, int>* p; // allocate an array of 10 elements // using mm's allocator: p = mm.get_allocator().allocate(10); // assign some values to array psize = sizeof(multimap<char, int>::value_type) * 10; cout << "The size of allocated array is " << psize << " bytes.\n"; mm.get_allocator().deallocate(p, 10); return 0; } |
chevron_right
filter_none
Output:
The size of allocated array is 80 bytes.
Recommended Posts:
- multimap::cbegin() and multimap::cend() in C++ STL
- multimap::crbegin() and multimap::crend() in C++ STL
- multimap size() function in C++ STL
- multimap value_comp() function in C++ STL
- multimap lower_bound() function in C++ STL
- multimap swap() function in C++ STL
- multimap upper_bound() function in C++ STL
- multimap clear() function in C++ STL
- multimap empty() function in C++ STL
- multimap::begin() and multimap::end() in C++ STL
- multimap maxsize() in C++ STL
- multimap insert() in C++ STL
- multimap::erase() in C++ STL
- multimap operator = in C++ STL
- multimap find() in C++ STL
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.



