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 iterator_category
, value_type
, difference_type
, pointer
and reference
are required to be obtained by inheriting from std::iterator<std::output_iterator_tag, void, void, void, void>.
#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:
[edit] See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4