operator< (<iterator>)
演算子の左側の反復子オブジェクトが右側の反復子オブジェクトより小さいかどうかを調べます。
template<class RandomIterator>
bool operator<(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
パラメーター
_Left
型 反復子オブジェクト。_Right
型 反復子オブジェクト。
戻り値
式の左辺の反復子である場合、式の右側の反復子未満true ; 右側の反復子の値以上である false。
解説
1 回の反復子オブジェクトはコンテナーに他の反復子オブジェクトによって要素アドレスより前にある要素をアドレス指定する別の未満です。 1 回の反復子オブジェクトが別の反復子オブジェクトと同じ要素またはコンテナーに他の反復子オブジェクトによって要素アドレスより後に出現する要素を指定した別の文字列より小さくないです。
使用例
// 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;
}
必要条件
ヘッダー: の <反復子>
名前空間: std