Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002 Copyright 2021-2022 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_NULLSTREAM_HPP
0009 #define BOOST_IO_NULLSTREAM_HPP
0010 
0011 #include <boost/config.hpp>
0012 #include <ostream>
0013 #include <streambuf>
0014 
0015 namespace boost {
0016 namespace io {
0017 
0018 template<class CharT, class Traits = std::char_traits<CharT> >
0019 class basic_nullbuf
0020     : public std::basic_streambuf<CharT, Traits> {
0021 protected:
0022     typename Traits::int_type overflow(typename Traits::int_type c)
0023         BOOST_OVERRIDE {
0024         return Traits::not_eof(c);
0025     }
0026 
0027     std::streamsize xsputn(const CharT*, std::streamsize n) BOOST_OVERRIDE {
0028         return n;
0029     }
0030 };
0031 
0032 namespace detail {
0033 
0034 template<class CharT, class Traits>
0035 class nullbuf {
0036 public:
0037     boost::io::basic_nullbuf<CharT, Traits>* buf() {
0038         return &buf_;
0039     }
0040 
0041 private:
0042     boost::io::basic_nullbuf<CharT, Traits> buf_;
0043 };
0044 
0045 } /* detail */
0046 
0047 template<class CharT, class Traits = std::char_traits<CharT> >
0048 class basic_onullstream
0049     : detail::nullbuf<CharT, Traits>
0050     , public std::basic_ostream<CharT, Traits> {
0051 public:
0052     basic_onullstream()
0053         : std::basic_ostream<CharT, Traits>(detail::nullbuf<CharT,
0054              Traits>::buf()) { }
0055 };
0056 
0057 typedef basic_onullstream<char> onullstream;
0058 typedef basic_onullstream<wchar_t> wonullstream;
0059 
0060 } /* io */
0061 } /* boost */
0062 
0063 #endif