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
deque
comparison operators
deque::deque
deque::~deque
member functions:
deque::assign
deque::at
deque::back
deque::begin
deque::clear
deque::empty
deque::end
deque::erase
deque::front
deque::get_allocator
deque::insert
deque::max_size
deque::operator=
deque::operator[]
deque::pop_back
deque::pop_front
deque::push_back
deque::push_front
deque::rbegin
deque::rend
deque::resize
deque::size
deque::swap


deque::max_size

public member function
size_type max_size () const;

Return maximum size

Returns the maximum number of elements that the deque container can hold.

This is the maximum potential size the container can reach due to system or library implementation limitations.

Parameters

none

Return Value

The maximum number of elements a deque container can have as its content.

Member type size_type is an unsigned integral type.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// deque::max_size
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  unsigned int i;
  deque<int> mydeque;
  cout << "Enter number of elements: ";
  cin >> i;
  if (i<mydeque.max_size()) mydeque.resize(i);
  else cout << "That size exceeds the limit.\n";
  return 0;
}


Here, member max_size is used to check beforehand whether the requested size will be allowed by member resize.

Complexity

Constant.

See also