Namespaces
Variants
Views
Actions

std::ostreambuf_iterator::ostreambuf_iterator

From cppreference.com
< cpp‎ | iterator‎ | ostreambuf iterator
Revision as of 14:59, 2 November 2012 by P12bot (Talk | contribs)

Template:ddcl list begin <tr class="t-dcl ">

<td >
ostreambuf_iterator(streambuf_type* buffer)
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl ">

<td >
ostreambuf_iterator(ostream_type& stream)
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

1) Constructs the iterator with the private streambuf_type* member set to buffer and the failed() bit set to false. The behavior is undefined if buffer is a null pointer.

2) Same as ostreambuf_iterator(stream.rdbuf())

Parameters

stream - the output stream whose rdbuf() will be accessed by this iterator
buffer - the output stream buffer to be accessed by this iterator

Exceptions

noexcept specification:  
noexcept
  

Example

#include <iostream>
#include <fstream>
#include <iterator>
int main()
{
    std::basic_filebuf<char> f;
    f.open("test.txt", std::ios::out);
 
    std::ostreambuf_iterator<char> out1(&f);
 
    std::ostreambuf_iterator<wchar_t> out2(std::wcout);
 
    *out1 = 'a';
    *out2 = L'a';
}