Common idioms for stl programming.
Treat an in-memory buffer as a stream without copying:
const char* c = "Hello world!";
buf_stream bs(c, c+12);
string s;
cin >> s;
assert (s == "Hello");
Ignore comments from an underlying istream:
stringstream ss;
ss << "# This is a comment" << endl;
ss << "10";
comment_stream cs(ss);
int x;
cs >> x;
assert(x == 10);
Embed tab-stops in an underlying ostream:
stringstream ss;
indent_stream is(ss);
ss << "Hello" << endl;
ss.tab();
ss << "World" << endl;
ss << "!" << endl;
ss.untab();
Treat a sequence of streams as a single stream (currently supports reads):
seq_stream ss;
stringstream s1("Hello world");
ss.push(s1);
filestream s2("file.txt");
ss.push(s2);
int x;
while (ss >> x) {
cout << x << endl;
}