std::ostreambuf_iterator - cppreference.com
From cppreference.com
| Defined in header |
||
|
|
(until C++17) | |
|
|
(since C++17) | |
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.
In a typical implementation, the only data members of std::ostreambuf_iterator are a pointer to the associated std::basic_streambuf and a boolean flag indicating if the end of file condition has been reached.
Member types
| Member type | Definition | ||||
iterator_category
|
std::output_iterator_tag
| ||||
value_type
|
void
| ||||
difference_type
|
| ||||
pointer
|
void
| ||||
reference
|
void
| ||||
char_type
|
CharT
| ||||
traits_type
|
Traits
| ||||
streambuf_type
|
std::basic_streambuf<CharT, Traits>
| ||||
ostream_type
|
std::basic_ostream<CharT, Traits>
|
|
Member types |
(until C++17) |
Member functions
constructs a new ostreambuf_iterator (public member function) [edit] | |
(destructor) (implicitly declared) |
destructs an ostreambuf_iterator (public member function) [edit] |
| writes a character to the associated output sequence (public member function) [edit] | |
| no-op (public member function) [edit] | |
| no-op (public member function) [edit] | |
| tests if output failed (public member function) [edit] |
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)); }
Output: