deque::end

Returns an iterator that addresses the location succeeding the last element in a deque.

const_iterator end( ) const;
iterator end( );

Return Value

A random-access iterator that addresses the location succeeding the last element in a deque. If the deque is empty, then deque::end == deque::begin.

Remarks

end is used to test whether an iterator has reached the end of its deque.

Example

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

int main( ) 
{
   using namespace std;
   deque <int> c1;
   deque <int>::iterator c1_Iter;
   
   c1.push_back( 10 );
   c1.push_back( 20 );
   c1.push_back( 30 );

   c1_Iter = c1.end( );
   c1_Iter--;
   cout << "The last integer of c1 is " << *c1_Iter << endl;

   c1_Iter--;
   *c1_Iter = 400;
   cout << "The new next-to-last integer of c1 is " << *c1_Iter << endl;

   // If a const iterator had been declared instead with the line:
   // deque <int>::const_iterator c1_Iter;
   // an error would have resulted when inserting the 400

   cout << "The deque is now:";
   for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
      cout << " " << *c1_Iter;
}

Output

The last integer of c1 is 30
The new next-to-last integer of c1 is 400
The deque is now: 10 400 30

Requirements

Header: <deque>

Namespace: std

See Also

Concepts

deque Class

deque Class Members

deque::begin and deque::end

Standard Template Library