operator== (<iterator>)

반복기 개체 연산자의 왼쪽에서 오른쪽 반복기 개체와 같은 경우를 테스트 합니다.

template<class RandomIterator1, class RandomIterator2>
    bool operator==(
        const move_iterator<RandomIterator1>& _Left,
        const move_iterator<RandomIterator2>& _Right
    );
template<class RandomIterator1, class RandomIterator2>
    bool operator==(
        const reverse_iterator<RandomIterator1>& _Left,
        const reverse_iterator<RandomIterator2>& _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
    개체 형식의 반복기입니다.

  • _Right
    개체 형식의 반복기입니다.

반환 값

true반복기 개체 같은 경우. false반복기 개체는 동일 하지 않은 경우.

설명

게는 같은 컨테이너 요소를에서 해결 하는 경우 반복기 개체 하나를 같습니다.두 반복기 컨테이너에서 다른 요소를 가리키는 경우 다음 같지 않습니다.

첫 번째 연산자는 두 개의 서식 파일은 모두 true가 반환 _Left 및 _Right 같은 반복기를 저장 합니다.세 번째 템플릿 연산자만 모두 true 반환 _Left 및 _Right 동일한 스트림 포인터를 저장 합니다.네 번째 템플릿은 연산자 반환 _Left.equal (_Right).

예제

// iterator_op_eq.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   vector<int> vec;
   for ( i = 1 ; i < 6 ; ++i )
   {
      vec.push_back ( 2 * 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 equal." << endl;
   else
      cout << "The iterators are not 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 equal." << endl;
   else
      cout << "The iterators are not equal." << endl;
}
  
  
  
  
  

요구 사항

헤더: <iterator>

네임 스페이스: std

참고 항목

참조

표준 템플릿 라이브러리