共用方式為


ostreambuf_iterator::failed

要插入的失敗的測試加入至輸出資料流緩衝區內。

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

請參閱

參考

ostreambuf_iterator Class

標準樣板程式庫