- typedef char_traits<char> traits_type;
- typedef traits_type::int_type int_type;
-
- Tee(ios& s, ofstream& f) : stream(s), file(f), stream_buf(s.rdbuf()) {}
- ~Tee() { set(false); }
-
- void set(bool b) { stream.rdbuf(b ? this : stream_buf); }
-
-private:
- int_type overflow(int_type c) {
-
- if (traits_type::eq_int_type(c, traits_type::eof()))
- return traits_type::not_eof(c);
-
- c = stream_buf->sputc(traits_type::to_char_type(c));
-
- if (!traits_type::eq_int_type(c, traits_type::eof()))
- c = file.rdbuf()->sputc(traits_type::to_char_type(c));
-
- return c;
- }
-
- int sync() {