diff options
Diffstat (limited to 'src/ios_save.hh')
| -rw-r--r-- | src/ios_save.hh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ios_save.hh b/src/ios_save.hh new file mode 100644 index 0000000..1abcf53 --- /dev/null +++ b/src/ios_save.hh @@ -0,0 +1,31 @@ +// -*- mode: c++; c-basic-offset: 2; -*- + +#ifndef IOS_SAVE_HH +#define IOS_SAVE_HH + +#include <ostream> + +class ios_save { +public: + ios_save(std::ostream& ostream) + : ostream_(ostream), save_(nullptr) { + save_.copyfmt(ostream); + } + + ios_save(ios_save const& save) + : ostream_(save.ostream_), save_(nullptr) { + save_.copyfmt(save.save_); + } + + ~ios_save() { + ostream_.copyfmt(save_); + } + + ios_save& operator=(ios_save const&) = delete; + +private: + std::ostream& ostream_; + std::ios save_; +}; + +#endif // IOS_SAVE_HH |
