Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is std::stringstream::flush() supposed to do anything?

std::ostream's have a flush() method which:

Writes uncommitted changes to the underlying output sequence.

What does that mean for an std::stringstream? If I understand correctly, it means there's nothing to be done for such a stream. Is this true?

like image 802
einpoklum Avatar asked Sep 10 '25 22:09

einpoklum


1 Answers

flush() triggers a call of the stream's rdbuf member's pubsync() method (which in turn calls sync() ). For string streams, the rdbuf is a std::basic_stringbuf, and as the link indicates, its pubsync()/sync() behavior is to do nothing.

Thus, indeed, your assumption is valid: std::stringstream::flush() does nothing.

like image 126
einpoklum Avatar answered Sep 13 '25 15:09

einpoklum