Search code examples
c++stringstreamstrstream

What is substitute for strstream's pcount and freeze in stringstream?


I have old c++ code using strstream and using pcount and freeze methods of the same. I want to use stringstream class instead. What are the substitute for pcount and freeze methods of strstream? The code is something like this:

strstream log; // this will change to: stringstream log;

if (log.pcount()) //????
{
    log << ends;
    *myLog << log.str() << logmsg;
}

log.freeze(0); //????

Solution

  • freeze() is something which has and need no replacement, its purpose is the handling of memory.

    log.pcount() can be replaced with log.str().size() if your stringstream is output only. If not, I don't think there is a good replacement. BTW, ends is unneeded as well.