Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:53:46

0001 /*
0002 Copyright 2019-2020 Glen Joseph Fernandes
0003 (glenjofe@gmail.com)
0004 
0005 Distributed under the Boost Software License, Version 1.0.
0006 (http://www.boost.org/LICENSE_1_0.txt)
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 } /* detail */
0042 } /* io */
0043 } /* boost */
0044 
0045 #endif