Delen via


map::crend

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

const_reverse_iterator crend( ) const;

Return Value

A const reverse bidirectional iterator that addresses the location succeeding the last element in a reversed map Class (the location that had preceded the first element in the unreversed map).

Remarks

crend is used with a reversed map just as map::end is used with a map.

With the return value of crend, the map object cannot be modified.

crend can be used to test to whether a reverse iterator has reached the end of its map.

The value returned by crend should not be dereferenced.

Example

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

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

   map <int, int> :: const_reverse_iterator m1_crIter;
   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_crIter = m1.crend( );
   m1_crIter--;
   cout << "The last element of the reversed map m1 is "
        << m1_crIter -> first << "." << endl;
}
The last element of the reversed map m1 is 1.

Requirements

Header: <map>

Namespace: std

See Also

Reference

map Class

Standard Template Library