array::crend

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

const_reverse_iterator crend( ) const;

A const reverse random-access iterator that addresses the location succeeding the last element in a reversed array (the location that had preceded the first element in the unreversed array).

crend is used with a reversed array just as array::cend is used with a array.

With the return value of crend (suitably decremented), the array object cannot be modified.

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

The value returned by crend should not be dereferenced.

// array_crend.cpp
// compile with: /EHsc
#include <array>
#include <iostream>

int main( )
{
   using namespace std;   
   array<int, 2> v1 = {1, 2};
   array<int, 2>::const_reverse_iterator v1_rIter;
   
   for ( v1_rIter = v1.rbegin( ) ; v1_rIter != v1.rend( ) ; v1_rIter++ )
      cout << *v1_rIter << endl;
}
2
1

Header: <array>

Namespace: std

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft