vector::crbegin

Returns a const reverse_iterator that points to the last element in the vector.

const_reverse_iterator crbegin( ) const;

Return Value

A const reverse random-access iterator addressing the last element in the 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( )
{
   vector <int> vec;
    vector <int>::iterator pos;
    vector <int>::const_reverse_iterator crpos;

    vec.push_back(1);
    vec.push_back(2);

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

    crpos = vec.crbegin();
    cout << "The first element of the reversed vector is "
        << *crpos << "." << endl;}
The first element of the vector is 1.
The first element of the reverse iteration is 2.

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector Class

Standard Template Library