operator!= (<iterator>)
如果在运算符左侧的迭代器对象与右侧,的迭代器对象不相等测试。
template<class RandomIterator>
bool operator!=(
const reverse_iterator<RandomIterator>& _Left,
const reverse_iterator<RandomIterator>& _Right
);
template<class Type, class CharType, class Traits, class Distance>
bool operator!=(
const istream_iterator<Type, CharType, Traits, Distance>& _Left,
const istream_iterator<Type, CharType, Traits, Distance>& _Right
);
template<class CharType, class Tr>
bool operator!=(
const istreambuf_iterator<CharType, Traits>& _Left,
const istreambuf_iterator<CharType, Traits>& _Right
);
参数
_Left
类型 iterator对象。_Right
类型 iterator对象。
返回值
true,如果迭代器对象不相等; false,如果迭代器对象相等。
备注
如果它们解决在容器,的相同元素的迭代器对象相同到另一个。 如果两个迭代器指向在容器的不同组件,则它们不相等。
示例
// iterator_op_ne.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
int i;
vector<int> vec;
for ( i = 1 ; i < 9 ; ++i )
{
vec.push_back ( i );
}
vector <int>::iterator vIter;
cout << "The 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 iterator rVPOS1 initially points to the first "
<< "element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
if ( rVPOS1 != rVPOS2 )
cout << "The iterators are not equal." << endl;
else
cout << "The iterators are equal." << endl;
rVPOS1++;
cout << "The iterator rVPOS1 now points to the second "
<< "element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
if ( rVPOS1 != rVPOS2 )
cout << "The iterators are not equal." << endl;
else
cout << "The iterators are equal." << endl;
}
要求
标头: <iterator>
命名空间: std