rtems-utils.h: Create ostream_guard

This commit is contained in:
Ryan Long
2021-07-20 09:51:34 -04:00
committed by Joel Sherrill
parent 23808864e3
commit 68348ad39f

View File

@@ -47,6 +47,26 @@ namespace rtems
bool real = false,
size_t line_length = 16,
uint32_t offset = 0);
/*
* Save and restore the output stream's settings.
*/
struct ostream_guard {
std::ostream& o;
std::ios_base::fmtflags flags;
ostream_guard (std::ostream& o_)
: o (o_),
flags (o_.flags ())
{
}
~ostream_guard ()
{
o.flags(flags);
}
};
}
}