测试对于两超出缓冲区迭代之间的等效性。
bool equal(
const istreambuf_iterator<CharType, Traits>& _Right
) const;
参数
- _Right
迭代器可以检查相等。
返回值
true,如果两 istreambuf_iterator的是关闭流迭代器,或者都不是关闭流;迭代器否则 false。
备注
范围通过对当前位置和关闭流迭代器的 istreambuf_iterator 定义,但,因为所有非关闭流迭代器是相当于在 equal 成员函数下,定义所有subranges使用 istreambuf_iterators.,不可能的。== 和 != 运算符具有相同的语义。
示例
// 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!
你好,世界! (请尝试该示例:"你好,世界!"然后插入的enter键到输出中,&使用一CTRL Z enter键组合退出):你好,世界!迭代器相等。
要求
标头: <iterator>
命名空间: std