
"Jonathan Turkanis" <technews@kangaroologic.com> wrote in message news:cgem4t$r20$1@sea.gmane.org...
"Pavel Vozenilek" <pavel_vozenilek@hotmail.com> wrote in message:
- 'tee' like output stream, they take data and re-send them all into two other streams
struct tee : boost::io::output_filter { tee(std::ostream& dest) : dest(dest) { }
template<typename Sink> void write(Sink& snk, char* s, std::streamsize n) { // Write to the downstream Sink boost::io::write(snk, s, n);
// Write to the stored ostream: dest.write(s, n); }
std::ostream& dest; };
Better: struct tee : boost::io::sink { tee(std::ostream& first, std::ostream& second) : first(first), second(second) { } void write(const char* s, std::streamsize n) { first.write(s, n); second.write(s, n); } std::ostream& first; std::ostream& second; }; std::ostream first; std::ostream second; boost::io::stream_facade<tee> out(tee(first, second)); out << "This is simpler and more efficient\n"; Jonathan