Compartilhar via


list::cend

Returns a const iterator that addresses the location succeeding the last element in a list.

const_iterator cend( ) const;

Return Value

A const bidirectional iterator that addresses the location succeeding the last element in a list Class. If the list is empty, then list::cend == list::begin.

Remarks

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

Example

// list_cend.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( ) 
{
   using namespace std;
   list <int> c1;
   list <int>::const_iterator c1_cIter;
   
   c1.push_back( 10 );
   c1.push_back( 20 );
   c1.push_back( 30 );

   c1_cIter = c1.cend( );
   c1_cIter--;
   cout << "The last integer of c1 is " << *c1_cIter << endl;
}
The last integer of c1 is 30

Requirements

Header: <list>

Namespace: std

See Also

Reference

list Class

Standard Template Library

Other Resources

list Class Members