I try the following code:
ostringstream oss;
streambuf *psbuf, *backup;
backup = oss.rdbuf();
psbuf = cout.rdbuf();
oss.rdbuf(psbuf);
oss << things << endl;
oss.rdbuf(backup);
But unfortunately I get this error:
error: too many arguments to function call, expected 0, have 1
oss.rdbuf(backup);
But rdbuf has two overloads:
get (1) basic_streambuf<char_type,traits_type>* rdbuf() const;
set (2) basic_streambuf<char_type,traits_type>* rdbuf (basic_streambuf<char_type,traits_type>* sb);
Yes I know it says basic_streambuf
but it really is just a typedef typedef basic_streambuf<char> streambuf;
, so it should work. Why is it not working?
basic_ostringstream
also define anotherrdbuf(basic_stringbuf*)
? – Tweedy