Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
multimap
comparison operators
multimap::multimap
multimap::~multimap
member functions:
multimap::begin
multimap::clear
multimap::count
multimap::empty
multimap::end
multimap::equal_range
multimap::erase
multimap::find
multimap::get_allocator
multimap::insert
multimap::key_comp
multimap::lower_bound
multimap::max_size
multimap::operator=
multimap::rbegin
multimap::rend
multimap::size
multimap::swap
multimap::upper_bound
multimap::value_comp


multimap::get_allocator

public member function
allocator_type get_allocator() const;

Get allocator

Returns the allocator object used to constuct the container.

Parameters

none

Return Value

The allocator.

Member type allocator_type is defined to the same as the fourth template parameter used to instantitate this specific multimap class (its Allocator type).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// multimap::get_allocator
#include <iostream>
#include <map>
using namespace std;
int main ()
{
  int psize;
  multimap<char,int> mymultimap;
  pair<const char,int>* p;
  // allocate an array of 5 elements using mymap's allocator:
  p=mymultimap.get_allocator().allocate(5);
  // assign some values to array
  psize = (int) sizeof(multimap<char,int>::value_type)*5;
  cout << "The allocated array has a size of " << psize << " bytes.\n";
  mymultimap.get_allocator().deallocate(p,5);
  return 0;
}

The example shows an elaborate way to allocate memory for an array of pairs using the same allocator used by the container.
A possible output is:
The allocated array has a size of 40 bytes.

Complexity

Constant.