共用方式為


ostreambuf_iterator::traits_type

A type that provides for the character traits type of the ostream_iterator.

typedef Traits traits_type;

Remarks

The type is a synonym for the template parameter Traits.

Example

// ostreambuf_iterator_traits_type.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;

   typedef ostreambuf_iterator<char>::char_type CHT1;
   typedef ostreambuf_iterator<char>::traits_type CHTR1;

   // ostreambuf_iterator for stream cout
   // with new line delimiter:
    ostreambuf_iterator< CHT1, CHTR1> charOutBuf ( cout );

   // Standard iterator interface for writing
   // elements to the output streambuf:
   cout << "The characters written to the output stream\n"
        << " by charOutBuf are: ";
   *charOutBuf = 'O';
   charOutBuf++;
   *charOutBuf = 'U';
   charOutBuf++;
   *charOutBuf = 'T';
   charOutBuf++;
   cout << "." << endl;
}
The characters written to the output stream
 by charOutBuf are: OUT.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

ostreambuf_iterator Class

Standard Template Library