다음을 통해 공유


ostreambuf_iterator::failed

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

bool failed( ) const throw( );

반환 값

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

설명

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

예제

// 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

참고 항목

참조

ostreambuf_iterator 클래스

표준 템플릿 라이브러리