Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

set::crend

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

const_reverse_iterator crend( ) const;

A const reverse bidirectional iterator that addresses the location succeeding the last element in a reversed set (the location that had preceded the first element in the unreversed set).

crend is used with a reversed set just as end is used with a set.

With the return value of crend, the set object cannot be modified. The value returned by crend should not be dereferenced.

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

// set_crend.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main() {
   using namespace std;   
   set <int> s1;
   set <int>::const_reverse_iterator s1_crIter;

   s1.insert( 10 );
   s1.insert( 20 );
   s1.insert( 30 );

   s1_crIter = s1.crend( );
   s1_crIter--;
   cout << "The last element in the reversed set is "
        << *s1_crIter << "." << endl;
}

The last element in the reversed set is 10.

Header: <set>

Namespace: std

Show:
© 2015 Microsoft