测试失败的插入到输出流缓冲区。
bool failed( ) const throw( );
返回值
true,如果插入到输出流缓冲区中没有失败之前;否则 false。
备注
如果为,则在指向成员 **operator=**的任何前面使用,为 subf_->sputc 的调用返回 eof,成员函数返回 true。
示例
// ostreambuf_iterator_failed.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
// ostreambuf_iterator for stream cout
ostreambuf_iterator<char> charOut ( cout );
*charOut = 'a';
charOut ++;
*charOut = 'b';
charOut ++;
*charOut = 'c';
cout << " are characters output individually." << endl;
bool b1 = charOut.failed ( );
if (b1)
cout << "At least one insertion failed." << endl;
else
cout << "No insertions failed." << endl;
}
要求
标头: <iterator>
命名空间: std