---
name: "std::ostreambuf_iterator"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::ostreambuf_iterator/3cxx"
---

# std::ostreambuf\_iterator(3cxx)

Provides output iterator semantics for streambufs.

## NAME

std::ostreambuf\_iterator\< \_CharT, \_Traits \> - Provides output iterator semantics for streambufs.

## SYNOPSIS

`#include <iterator>`

Inherits **std::iterator\< output\_iterator\_tag, void, void, void, void \>**.

### Public Types

**typedef** **output\_iterator\_tag** **iterator\_category**\
 One of the **tag types**.  **typedef** **void** **pointer**\
 This type represents a pointer-to-value\_type.  **typedef** **void** **reference**\
 This type represents a reference-to-value\_type.  **typedef** **void** **value\_type**\
 The type 'pointed to' by the iterator.

**using** **difference\_type** = ptrdiff\_t\
 Public typedefs.  **typedef** \_CharT **char\_type**\
 Public typedefs.  **typedef** \_Traits **traits\_type**\
 Public typedefs.  **typedef** **basic\_streambuf**\< \_CharT, \_Traits \> **streambuf\_type**\
 Public typedefs.  **typedef** **basic\_ostream**\< \_CharT, \_Traits \> **ostream\_type**\
 Public typedefs.

### Public Member Functions

**ostreambuf\_iterator** (**ostream\_type** &**\_\_s**) noexcept\
 Construct output iterator from ostream.  **ostreambuf\_iterator** (**streambuf\_type** \***\_\_s**) noexcept\
 Construct output iterator from streambuf.  **ostreambuf\_iterator** & **\_M\_put** (const \_CharT \***\_\_ws**, **streamsize** **\_\_len**)\
 bool **failed** () const noexcept\
 Return true if previous operator=() failed.  **ostreambuf\_iterator** & **operator\*** ()\
 Return \*this.  **ostreambuf\_iterator** & **operator++** ()\
 Return \*this.  **ostreambuf\_iterator** & **operator++** (int)\
 Return \*this.  **ostreambuf\_iterator** & **operator=** (\_CharT \_\_c)\
 Write character to streambuf. Calls streambuf.sputc().

### Friends

template\<**typename** **\_CharT2** \> \_\_gnu\_cxx::\_\_enable\_if\< \_\_is\_char\< **\_CharT2** \>::\_\_value, **ostreambuf\_iterator**\< **\_CharT2** \> \>::\_\_type **copy** (**istreambuf\_iterator**\< **\_CharT2** \>, **istreambuf\_iterator**\< **\_CharT2** \>, **ostreambuf\_iterator**\< **\_CharT2** \>)\

## Detailed Description

### template\<typename \_CharT, typename \_Traits\>

class std::ostreambuf\_iterator\< \_CharT, \_Traits \>"Provides output iterator semantics for streambufs.

## Member Typedef Documentation

### template\<typename \_CharT , typename \_Traits \> typedef \_CharT std::ostreambuf\_iterator\< \_CharT, \_Traits \>::char\_type

Public typedefs.

### template\<typename \_CharT , typename \_Traits \> using std::ostreambuf\_iterator\< \_CharT, \_Traits \>::difference\_type = ptrdiff\_t

Public typedefs.

### typedef output\_iterator\_tag std::iterator\< output\_iterator\_tag , void , void , void , void \>::iterator\_category` [inherited]`

One of the **tag types**.

### template\<typename \_CharT , typename \_Traits \> typedef basic\_ostream\<\_CharT, \_Traits\> std::ostreambuf\_iterator\< \_CharT, \_Traits \>::ostream\_type

Public typedefs.

### typedef void std::iterator\< output\_iterator\_tag , void , void , void , void \>::pointer` [inherited]`

This type represents a pointer-to-value\_type.

### typedef void std::iterator\< output\_iterator\_tag , void , void , void , void \>::reference` [inherited]`

This type represents a reference-to-value\_type.

### template\<typename \_CharT , typename \_Traits \> typedef basic\_streambuf\<\_CharT, \_Traits\> std::ostreambuf\_iterator\< \_CharT, \_Traits \>::streambuf\_type

Public typedefs.

### template\<typename \_CharT , typename \_Traits \> typedef \_Traits std::ostreambuf\_iterator\< \_CharT, \_Traits \>::traits\_type

Public typedefs.

### typedef void std::iterator\< output\_iterator\_tag , void , void , void , void \>::value\_type` [inherited]`

The type 'pointed to' by the iterator.

## Constructor & Destructor Documentation

### template\<typename \_CharT , typename \_Traits \> std::ostreambuf\_iterator\< \_CharT, \_Traits \>::ostreambuf\_iterator (ostream\_type & \_\_s)` [inline]`, ` [noexcept]`

Construct output iterator from ostream.

### template\<typename \_CharT , typename \_Traits \> std::ostreambuf\_iterator\< \_CharT, \_Traits \>::ostreambuf\_iterator (streambuf\_type \* \_\_s)` [inline]`, ` [noexcept]`

Construct output iterator from streambuf.

## Member Function Documentation

### template\<typename \_CharT , typename \_Traits \> bool std::ostreambuf\_iterator\< \_CharT, \_Traits \>::failed () const` [inline]`, ` [noexcept]`

Return true if previous operator=() failed.

### template\<typename \_CharT , typename \_Traits \> ostreambuf\_iterator & std::ostreambuf\_iterator\< \_CharT, \_Traits \>::operator\* ()` [inline]`

Return \*this.

### template\<typename \_CharT , typename \_Traits \> ostreambuf\_iterator & std::ostreambuf\_iterator\< \_CharT, \_Traits \>::operator++ ()` [inline]`

Return \*this.

### template\<typename \_CharT , typename \_Traits \> ostreambuf\_iterator & std::ostreambuf\_iterator\< \_CharT, \_Traits \>::operator++ (int)` [inline]`

Return \*this.

### template\<typename \_CharT , typename \_Traits \> ostreambuf\_iterator & std::ostreambuf\_iterator\< \_CharT, \_Traits \>::operator= (\_CharT \_\_c)` [inline]`

Write character to streambuf. Calls streambuf.sputc().

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
