VCCC  2024.05
VisualCamp Common C++ library
ios_flags_saver.hpp
Go to the documentation of this file.
1 # /*
2 # * Created by YongGyu Lee on 2021/03/20.
3 # */
4 #
5 # ifndef VCCC_LOG_IOS_FLAGS_SAVER_HPP
6 # define VCCC_LOG_IOS_FLAGS_SAVER_HPP
7 #
8 # include <ios>
9 
10 namespace vccc {
11 
14 
31 template<typename Stream>
33  public:
34  using stream_type = Stream;
35 
36  explicit IOSFlagsSaver(stream_type& stream) : stream(stream), flags(stream.flags()) {}
37  ~IOSFlagsSaver() { stream.flags(flags); }
38 
39  private:
40  std::ios_base::fmtflags flags;
41  stream_type& stream;
42 };
43 
45 
46 } // namespace vccc
47 
48 #endif // VCCC_LOG_IOS_FLAGS_SAVER_HPP
RAII wrapper that restores stream's flags on destroyed.
Definition: ios_flags_saver.hpp:32
~IOSFlagsSaver()
Definition: ios_flags_saver.hpp:37
IOSFlagsSaver(stream_type &stream)
Definition: ios_flags_saver.hpp:36
Stream stream_type
Definition: ios_flags_saver.hpp:34
Definition: directory.h:12