operator> (<iterator>)
如果在运算符左侧的迭代器对象与右侧,的迭代器对象。测试。
template<class RandomIterator>
bool operator>(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
参数
_Left
类型迭代器对象。_Right
类型迭代器对象。
返回值
true,如果表达式左侧的迭代器比在表达式的右侧迭代器大于; false,则小于或等于右侧的迭代器。
备注
一个迭代对象与另一个大于,则解决在容器大于另一个迭代器对象格地址的后面的元素。 一个迭代对象与另一个不大于,则解决元素和其他迭代器对象相同或在容器大于另一个迭代器对象格地址的前的元素。
示例
// iterator_op_gt.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 ( ),
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 greater than "
<< "the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is less than or "
<< "equal to the iterator rVPOS2." << endl;
rVPOS1++;
cout << "The iterator rVPOS1 now points to the second "
<< "element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
if ( rVPOS1 > rVPOS2 )
cout << "The iterator rVPOS1 is greater than "
<< "the iterator rVPOS2." << endl;
else
cout << "The iterator rVPOS1 is less than or "
<< "equal to the iterator rVPOS2." << endl;
}
要求
标头: <iterator>
命名空间: std