Change basic_string_stream to not clear the buffer on flush
If the buffer is cleared when flushed, the class does not function correctly as a string builder. For example, if a string is built with a newline inside, everything before the newline will be cleared and the string will be incomplete. Clearing the buffer on flush only makes sense for applications such as logging or writting to a file.
This commit is contained in:
parent
82f60f4767
commit
4dd979ef54
@ -49,14 +49,11 @@ public:
|
|||||||
* \brief Flushes the buffer to the underlying output sequence and
|
* \brief Flushes the buffer to the underlying output sequence and
|
||||||
* clears the buffer
|
* clears the buffer
|
||||||
*
|
*
|
||||||
* By default simply clears the buffer, but can be overriden to
|
* By default is a NOP, but can be overriden to provide more
|
||||||
* provide more functionality. This function is called internally when
|
* functionality. This function is called internally when
|
||||||
* mtl::flush and mtl::endl are piped to the stream. The derived
|
* mtl::flush and mtl::endl are piped to the stream.
|
||||||
* class must be sure to clear the buffer when finished.
|
|
||||||
*/
|
*/
|
||||||
virtual void flush() {
|
virtual void flush() { }
|
||||||
m_str.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
m_str.clear();
|
m_str.clear();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user