All the other posts tell me to change my compiler, but I can't since I'm supposed to be working with this compiler. Please help!
void foo(ostringstream &os) {
ostringstream temp;
temp << 0;
//do something
os.swap(temp);
}
^I can' really upload the do-something part, since it's a part of a school project, but the compiler is giving me an error at: os.swap(temp);
I also tried the =operator and that didn't work as well
You can use the
strmember function instd::ostringstreamto both obtain the buffer from the temporary stream and set the buffer passed tofoo.Alternatively you can eliminate the use of a temporary stream by clearing the buffer in
osas soon as you enterfooand output directly toos. Your post doesn't provide enough information to determine if this will be useful to you but it's an option.