istreambuf_iterator::equal
相等測試在兩個輸入資料流緩衝區Iterator之間。
bool equal(
const istreambuf_iterator<CharType, Traits>& _Right
) const;
參數
- _Right
Iterator可以檢查是否相等。
傳回值
true ,如果兩個 istreambuf_iterator的是關閉資料流Iterator,或者兩者都不是關閉資料流Iterator,否則 false。
備註
範圍是由目前位置和關閉資料流Iterator的 istreambuf_iterator 定義,但是,,因為所有非關閉資料流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!
Hello world! (請嘗試這個範例:「Hello world!」接著會插入至輸出中, __AMP__RYAN使用哪一個輸入鍵CTRL Z輸入按鍵組合結束):Hello world!Iterator相等。
需求
標題: <iterator>
命名空間: std