Add width field to StreamState

This commit is contained in:
Jeffrey Walton 2017-03-18 08:18:05 -04:00
parent ad47231dc0
commit 13bcfbe249
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

View File

@ -126,20 +126,22 @@ class StreamState
{ {
public: public:
StreamState(std::ostream& out) StreamState(std::ostream& out)
: m_out(out), m_prec(out.precision()), m_fmt(out.flags()), m_fill(out.fill()) : m_out(out), m_prec(out.precision()), m_width(out.width()), m_fmt(out.flags()), m_fill(out.fill())
{ {
} }
~StreamState() ~StreamState()
{ {
m_out.precision(m_prec);
m_out.flags(m_fmt);
m_out.fill(m_fill); m_out.fill(m_fill);
m_out.flags(m_fmt);
m_out.width(m_width);
m_out.precision(m_prec);
} }
private: private:
std::ostream& m_out; std::ostream& m_out;
std::streamsize m_prec; std::streamsize m_prec;
std::streamsize m_width;
std::ios_base::fmtflags m_fmt; std::ios_base::fmtflags m_fmt;
std::ostream::char_type m_fill; std::ostream::char_type m_fill;
}; };