Information
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.

map::crbegin

Returns a const iterator addressing the first element in a reversed map.

const_reverse_iterator crbegin( ) const;

A const reverse bidirectional iterator addressing the first element in a reversed map Class or addressing what had been the last element in the unreversed map.

crbegin is used with a reversed map just as map::begin is used with a map.

With the return value of crbegin, the map object cannot be modified

crbegin can be used to iterate through a map backwards.

// map_crbegin.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.crbegin( );
   cout << "The first element of the reversed map m1 is "
        << m1_crIter -> first << "." << endl;
}
The first element of the reversed map m1 is 3.

Header: <map>

Namespace: std

Show:
© 2014 Microsoft