다음을 통해 공유


istreambuf_iterator::equal

Tests for equivalence between two input stream buffer iterators.

bool equal(
   const istreambuf_iterator<CharType, Traits>& _Right
) const;

매개 변수

  • _Right
    The iterator for which to check for equality.

반환 값

true if both istreambuf_iterators are end-of-stream iterators or if neither is an end-of-stream iterator; otherwise false.

설명

A range is defined by the istreambuf_iterator to the current position and the end-of-stream iterator, but since all non-end-of stream iterators are equivalent under the equal member function, it is not possible to define any subranges using istreambuf_iterators. The == and != operators have the same semantics.

예제

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

int main( )
{
   using namespace std;

   cout << "(Try the example: 'Hello world!'\n"
        << " then an Enter key to insert into the output,\n"
        << " & use a ctrl-Z Enter key combination to exit): ";

   istreambuf_iterator<char> charReadIn1 ( cin );
   istreambuf_iterator<char> charReadIn2 ( cin );

   bool b1 = charReadIn1.equal ( charReadIn2 );

   if (b1)
      cout << "The iterators are equal." << endl;
   else
      cout << "The iterators are not equal." << endl;
}
  Hello world!

FakePre-3845126ea67f40cf9357afa18f072863-858072d548d940f2afde93a5dd98d653

요구 사항

헤더: <iterator>

네임스페이스: std

참고 항목

참조

istreambuf_iterator 클래스

표준 템플릿 라이브러리