summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2014-09-19 10:35:09 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2014-09-19 10:35:09 -0400
commit32c111eda40269b0047ba3c109b7a2ba878d2544 (patch)
treee806998d437a52de4818a1bd4110ae1c96768ea9 /src/base
parentaddfd89dced4e2429050663db93ad37790f37a78 (diff)
downloadgem5-32c111eda40269b0047ba3c109b7a2ba878d2544.tar.xz
misc: Restore ostream flags where needed
This patch ensures we adhere to the normal ostream usage rules, and restore the flags after modifying them.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/cprintf_formats.hh8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/base/cprintf_formats.hh b/src/base/cprintf_formats.hh
index 991238dee..5b3b34432 100644
--- a/src/base/cprintf_formats.hh
+++ b/src/base/cprintf_formats.hh
@@ -88,6 +88,8 @@ _format_integer(std::ostream &out, const T &data, Format &fmt)
{
using namespace std;
+ ios::fmtflags flags(out.flags());
+
switch (fmt.base) {
case Format::hex:
out.setf(std::ios::hex, std::ios::basefield);
@@ -137,6 +139,8 @@ _format_integer(std::ostream &out, const T &data, Format &fmt)
out.setf(std::ios::uppercase);
out << data;
+
+ out.flags(flags);
}
template <typename T>
@@ -145,6 +149,8 @@ _format_float(std::ostream &out, const T &data, Format &fmt)
{
using namespace std;
+ ios::fmtflags flags(out.flags());
+
switch (fmt.float_format) {
case Format::scientific:
if (fmt.precision != -1) {
@@ -189,6 +195,8 @@ _format_float(std::ostream &out, const T &data, Format &fmt)
}
out << data;
+
+ out.flags(flags);
}
template <typename T>