#include #include #include #include "sequence_buffer.hpp" int main() { using namespace std; namespace sb = sequence_buffer; vector v1; // make an output buffer from the vector typedef sb::push_back_sequence > seq1; seq1 s1(v1); sb::output_buffer b1(s1); // redirect cout to the buffer basic_streambuf* cout_buf = cout.rdbuf(&b1); cout << "Redirect this text" << endl; // make an input buffer from the vector typedef sb::stl_input_sequence::const_iterator> seq2; seq2 s2(v1.begin(), v1.end()); sb::input_buffer b2(s2); // copy the input buffer-vector to the original cout buffer copy(istreambuf_iterator(&b2), istreambuf_iterator(), ostreambuf_iterator(cout_buf)); cout.rdbuf(cout_buf); return 0; }