共用方式為


ostreambuf_iterator Class

The template class ostreambuf_iterator describes an output iterator object that writes successive character elements onto the output stream with the extraction operator>>. The ostreambuf_iterators differ from those of the ostream_iterator Class in having characters instead of a generic type at the type of object being inserted into the output stream.

template <  
   class CharType = char 
   class Traits = char_traits<CharType> 
>

Parameters

  • CharType
    The type that represents the character type for the ostreambuf_iterator. This argument is optional and the default value is char*.*

  • Traits
    The type that represents the character type for the ostreambuf_iterator. This argument is optional and the default value is char_traits<CharType>.

Remarks

The ostreambuf_iterator class must satisfy the requirements for an output iterator. Algorithms can be written directly to output streams using an ostreambuf_iterator. The class provides a low-level stream iterator that allows access to the raw (unformatted) I/O stream in the form of characters and the ability to bypass the buffering and character translations associated with the high-level stream iterators.

Constructors

ostreambuf_iterator

Constructs an ostreambuf_iterator that is initialized to write characters to the output stream.

Typedefs

char_type

A type that provides for the character type of the ostreambuf_iterator.

ostream_type

A type that provides for the stream type of the ostream_iterator.

streambuf_type

A type that provides for the stream type of the ostreambuf_iterator.

traits_type

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

Member Functions

failed

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

Operators

operator*

Dereferencing operator used to implement the output iterator expression *i = x.

operator++

A nonfunctional increment operator that returns an ostreambuf_iterator to the same object it addressed before the operation was called.

operator=

The operator inserts a character into the associated stream buffer.

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

<iterator>

Thread Safety in the C++ Standard Library

Standard Template Library