operator<= (<iterator>)
Test se l'oggetto iteratori a sinistra dell'operatore è minore o uguale all'oggetto iteratori a destra.
template<class RandomIterator>
bool operator<=(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
Parametri
_Left
Un oggetto l'iteratore del tipo._Right
Un oggetto l'iteratore del tipo.
Valore restituito
Setrue l'iteratore a sinistra dell'espressione è minore o uguale a quelloiteratore lato destro dell'espressione; false se è maggiore dell'iteratore a destra.
Note
Un oggetto di iteratore è minore o uguale a un altro se è destinata allo stesso elemento o un elemento che si verifica in precedenza nel contenitore che l'elemento indirizzato altro oggetto di iteratore.Un oggetto di iteratore è maggiore di un altro se è destinata a un elemento che si verifica più avanti nel contenitore che l'elemento indirizzato altro oggetto di iteratore.
Esempio
// iterator_op_le.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
int i;
vector<int> vec;
for (i = 0 ; i < 6 ; ++i ) {
vec.push_back ( 2 * i );
}
vector <int>::iterator vIter;
cout << "The initial vector vec is: ( ";
for ( vIter = vec.begin( ) ; vIter != vec.end( ); vIter++)
cout << *vIter << " ";
cout << ")." << endl;
vector <int>::reverse_iterator rVPOS1 = vec.rbegin ( ) + 1,
rVPOS2 = vec.rbegin ( );
cout << "The iterator rVPOS1 initially points to the "
<< "second element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
cout << "The iterator rVPOS2 initially points to the "
<< "first element\n in the reversed sequence: "
<< *rVPOS2 << "." << endl;
if ( rVPOS1 <= rVPOS2 )
cout << "The iterator rVPOS1 is less than or "
<< "equal to the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is greater than "
<< "the iterator rVPOS2." << endl;
rVPOS2++;
cout << "The iterator rVPOS2 now points to the second "
<< "element\n in the reversed sequence: "
<< *rVPOS2 << "." << endl;
if ( rVPOS1 <= rVPOS2 )
cout << "The iterator rVPOS1 is less than or "
<< "equal to the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is greater than "
<< "the iterator rVPOS2." << endl;
}
Requisiti
intestazione: <iterator>
Spazio dei nomi: deviazione standard