list::crbegin

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

const_reverse_iterator rbegin( ) const;

Return Value

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

Remarks

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

With the return value of crbegin, the list object cannot be modified. list::rbegin can be used to iterate through a list backwards.

Example

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

int main( ) 
{
   using namespace std;
   list <int> c1;
   list <int>::const_reverse_iterator c1_crIter;

   c1.push_back( 10 );
   c1.push_back( 20 );
   c1.push_back( 30 );
   c1_crIter = c1.crbegin( );
   cout << "The last element in the list is " << *c1_crIter << "." << endl;
}
The last element in the list is 30.

Requirements

Header: <list>

Namespace: std

See Also

Reference

list Class

Standard Template Library