Compartilhar via


ostreambuf_iterator::failed

Tests for failure of an insertion into the output stream buffer.

bool failed( ) const throw( );

Return Value

true if no insertion into the output stream buffer has failed earlier; otherwise false.

Remarks

The member function returns true if, in any prior use of member operator=, the call to subf_->sputc returned eof.

Example

// 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;
}
abc are characters output individually.
No insertions failed.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

ostreambuf_iterator Class

Standard Template Library

Other Resources

ostreambuf_iterator Members