common: restore constructor fmtflags on clear

This is to prevent fmtflags changes from a previous use (e.g. debug message)
leaking into the the next (i.e. the next debug message).

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2019-01-02 10:07:45 -08:00
parent cb1e7e5fd0
commit d0355acb36
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB

View File

@ -92,7 +92,7 @@ template<std::size_t SIZE>
class StackStringStream : public std::basic_ostream<char>
{
public:
StackStringStream() : basic_ostream<char>(&ssb) {}
StackStringStream() : basic_ostream<char>(&ssb), default_fmtflags(flags()) {}
StackStringStream(const StackStringStream& o) = delete;
StackStringStream& operator=(const StackStringStream& o) = delete;
StackStringStream(StackStringStream&& o) = delete;
@ -101,6 +101,7 @@ public:
void reset() {
clear(); /* reset state flags */
flags(default_fmtflags); /* reset fmtflags to constructor defaults */
ssb.clear();
}
@ -110,6 +111,7 @@ public:
private:
StackStringBuf<SIZE> ssb;
fmtflags const default_fmtflags;
};
/* In an ideal world, we could use StackStringStream indiscriminately, but alas