Luatic
Luatic

Reputation: 11201

Buffer-based stringstream without copying

Suppose I have two APIs that I need to interact with:

I'd like to use this buffer for a std::istringstream, but if I'm not mistaken, I'll have to turn the raw character buffer into a std::string first, copying its contents. I'd like to avoid that.

So my question is: Is there a way I could directly make an istringstream read from a buffer without copying the buffer using the stdlib, and without writing my own bufferstream class?

Is there a good reason for istringstreams being restricted to, well, strings - especially since using strings as buffers is considered bad practice?

Upvotes: 0

Views: 101

Answers (0)

Related Questions