File indexing completed on 2025-12-16 09:53:46
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_IO_DETAIL_OSTREAM_GUARD_HPP
0009 #define BOOST_IO_DETAIL_OSTREAM_GUARD_HPP
0010
0011 #include <boost/config.hpp>
0012 #include <iosfwd>
0013
0014 namespace boost {
0015 namespace io {
0016 namespace detail {
0017
0018 template<class Char, class Traits>
0019 class ostream_guard {
0020 public:
0021 explicit ostream_guard(std::basic_ostream<Char, Traits>& os) BOOST_NOEXCEPT
0022 : os_(&os) { }
0023
0024 ~ostream_guard() BOOST_NOEXCEPT_IF(false) {
0025 if (os_) {
0026 os_->setstate(std::basic_ostream<Char, Traits>::badbit);
0027 }
0028 }
0029
0030 void release() BOOST_NOEXCEPT {
0031 os_ = 0;
0032 }
0033
0034 private:
0035 ostream_guard(const ostream_guard&);
0036 ostream_guard& operator=(const ostream_guard&);
0037
0038 std::basic_ostream<Char, Traits>* os_;
0039 };
0040
0041 }
0042 }
0043 }
0044
0045 #endif