vector::crbegin

Returns a const iterator to the first element in a reversed vector.

const_reverse_iterator crbegin( ) const;

Return Value

A const reverse random-access iterator addressing the first element in a reversed vector Class or addressing what had been the last element in the unreversed vector.

Remarks

With the return value of crbegin, the vector object cannot be modified.

Example

// vector_crbegin.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;   
   vector <int> v1;
   vector <int>::iterator v1_Iter;
   vector <int>::const_reverse_iterator v1_rIter;
   
   v1.push_back( 1 );
   v1.push_back( 2 );

   v1_Iter = v1.begin( );
   cout << "The first element of vector is "
        << *v1_Iter << "." << endl;

   v1_rIter = v1.crbegin( );
   cout << "The first element of the reversed vector is "
        << *v1_rIter << "." << endl;
}
The first element of vector is 1.
The first element of the reversed vector is 2.

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector Class

Standard Template Library

Other Resources

vector Members