Share via


map::cend

Returns a const past-the-end iterator.

const_iterator cend( ) const;

Return Value

The past-the-end iterator. If the map Class is empty, then map::cend() == map::begin().

Remarks

cend is used to test whether an iterator has passed the end of its map.

The value returned by cend should not be dereferenced.

Example

// map_cend.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   map <int, int> m1;

   map <int, int> :: const_iterator m1_cIter;
   typedef pair <int, int> Int_Pair;

   m1.insert ( Int_Pair ( 1, 10 ) );
   m1.insert ( Int_Pair ( 2, 20 ) );
   m1.insert ( Int_Pair ( 3, 30 ) );

   m1_cIter = m1.cend( );
   m1_cIter--;
   cout << "The value of the last element of m1 is:\n" 
        << m1_cIter -> second << endl;
}
The value of the last element of m1 is:
30

Requirements

Header: <map>

Namespace: std

See Also

Reference

map Class

Standard Template Library

Other Resources

map Members