Section
std::ostreambuf_iterator
std::ostreambuf_iterator is a single-pass LegacyOutputIterator that writes successive characters into the std::basic_streambuf object for which it was constructed. The actual write operation is performed when the iterator (whether dereferenced or not) is assigned to. Incrementing the std::ostreambuf_iterator is a no-op.
# Declarations
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator
: public std::iterator<std::output_iterator_tag, void, void, void, void>
(until C++17)
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator;
(since C++17)
# Example
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
int main()
{
std::string s = "This is an example\n";
std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout));
}