operator< (<iterator>)
Test se l'oggetto iteratori a sinistra dell'operatore è inferiore all'oggetto iteratori a destra.
template<class RandomIterator>
bool operator<(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
Parametri
_Left
Un oggetto di tipo iterator._Right
Un oggetto di tipo iterator.
Valore restituito
Setrue l'iteratore a sinistra dell'espressione è minore dell'iteratore lato destro dell'espressione; false se è maggiore o uguale all'iteratore a destra.
Note
Un oggetto di iteratore è inferiore a un altro se è destinata a un elemento che si verifica in precedenza nel contenitore che l'elemento indirizzato altro oggetto di iteratore.Un oggetto iteratori non è inferiore a un altro se è destinata allo stesso elemento dell'altro oggetto iteratori o un elemento che si verifica più avanti nel contenitore che l'elemento indirizzato altro oggetto di iteratore.
Esempio
// iterator_op_lt.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;
// Initializing reverse_iterators to the last element
vector <int>::reverse_iterator rVPOS1 = vec.rbegin ( ),
rVPOS2 = vec.rbegin ( );
cout << "The iterators rVPOS1& rVPOS2 initially point to the "
<< "first element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
if ( rVPOS1 < rVPOS2 )
cout << "The iterator rVPOS1 is less than"
<< " the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is not less 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"
<< " the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is not less than"
<< " the iterator rVPOS2." << endl;
}
Requisiti
intestazione: <iterator>
Spazio dei nomi: deviazione standard