Best way to store stream data
I'm making a game message system and using boost::serialize to convert message data into streams and sending it. This works fine for transmitting messages instantly as I can send off the reference to the stream.
However I would like to queue up messages as well in some circumstances. I am not sure what the best way to store the data would be.
I tried std::queue<std::stringstream>
but that just errors lots.
std::bitset looks开发者_JS百科 semi promising, but I'm not sure.
Or is this completely bonkers?
Try std::queue<std::vector<char> >
. The stringstream you tried before isn't copyable, so just copy the bytes. You could also use string as the value type in the queue, since that's probably what you'll be getting out of the stringstream.
精彩评论