The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.



Returns a reference to the element at a specified location in the deque.

      reference at(
   size_type _Pos
const_reference at(
   size_type _Pos
) const;


The subscript (or position number) of the element to reference in the deque.

If _Pos is greater than the size of the deque, at throws an exception.

If the return value of at is assigned to a const_reference, the deque object cannot be modified. If the return value of at is assigned to a reference, the deque object can be modified.


// deque_at.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>

int main( ) 
   using namespace std;
   deque <int> c1;

   c1.push_back( 10 );
   c1.push_back( 20 );

   const int& i = 0 );
   int& j = 1 );
   cout << "The first element is " << i << endl;
   cout << "The second element is " << j << endl;
The first element is 10
The second element is 20


Header: <deque>

Namespace: std