How can I get the same strstream functionality now that's deprecated?

Posted by chila on Stack Overflow See other posts from Stack Overflow or by chila
Published on 2010-06-08T20:09:55Z Indexed on 2010/06/08 20:12 UTC
Read the original article Hit count: 202

Filed under:

I use to write code like this:

void fun(char *buff, unsigned size)
{
    std::strstream str(buff, size);
    str << "hello world: " << 5;
}

so I can use stream output over an arbitrary buffer. I've found this technique both efficient (no allocations) and useful (streams!). Now that std::strstream is deprecated, how can I get the same speed+flexibility that I can get with this code?

© Stack Overflow or respective owner

Related posts about c++