multimap::max_size | public member function |
size_type max_size () const; |
Return maximum size
Returns the maximum number of elements that the multimap container object can hold.
This is the maximum potential size the container can reach due to system or library implementation limitations.
Parameters
noneReturn Value
The maximum number of elements the multimap container can have as its content.Member type size_type is an unsigned integral type.
Example
// multimap::max_size #include <iostream> #include <map> using namespace std; int main () { int i; multimap<int,int> mymultimap; if (mymultimap.max_size()>1000) { for (i=0; i<1000; i++) mymultimap.insert(pair<int,int>(i,0)); cout << "The multimap contains 1000 elements.\n"; } else cout << "The multimap could not hold 1000 elements.\n"; return 0; } |
Here, member max_size is used to check beforehand whether the multimap will allow for 1000 elements to be inserted.
Complexity
Constant.See also
multimap::size | Return container size (public member function) |