File indexing completed on 2025-01-18 09:52:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_TEST_UTILS_NULLSTREAM_HPP
0017 #define BOOST_TEST_UTILS_NULLSTREAM_HPP
0018
0019
0020 #include <ostream> // for std::basic_ostream
0021 #include <streambuf> // for std::basic_streambuf
0022 #include <string> // for std::char_traits
0023
0024
0025 #include <boost/utility/base_from_member.hpp>
0026
0027 #include <boost/test/detail/suppress_warnings.hpp>
0028
0029
0030
0031 namespace boost {
0032
0033
0034
0035
0036
0037
0038
0039
0040 template<typename CharType, class CharTraits = ::std::char_traits<CharType> >
0041 class basic_nullbuf : public ::std::basic_streambuf<CharType, CharTraits> {
0042 typedef ::std::basic_streambuf<CharType, CharTraits> base_type;
0043 public:
0044
0045 typedef typename base_type::char_type char_type;
0046 typedef typename base_type::traits_type traits_type;
0047 typedef typename base_type::int_type int_type;
0048 typedef typename base_type::pos_type pos_type;
0049 typedef typename base_type::off_type off_type;
0050
0051
0052
0053 protected:
0054
0055
0056
0057
0058
0059
0060
0061
0062 virtual ::std::streamsize xsputn( char_type const* , ::std::streamsize n ) { return n; }
0063 virtual int_type overflow( int_type c = traits_type::eof() ) { return traits_type::not_eof( c ); }
0064 };
0065
0066 typedef basic_nullbuf<char> nullbuf;
0067 typedef basic_nullbuf<wchar_t> wnullbuf;
0068
0069
0070
0071
0072
0073
0074 #ifdef BOOST_MSVC
0075 # pragma warning(push)
0076 # pragma warning(disable: 4355)
0077 #endif
0078
0079 template< typename CharType, class CharTraits = ::std::char_traits<CharType> >
0080 class basic_onullstream : private boost::base_from_member<basic_nullbuf<CharType, CharTraits> >
0081 , public ::std::basic_ostream<CharType, CharTraits> {
0082 typedef boost::base_from_member<basic_nullbuf<CharType, CharTraits> > pbase_type;
0083 typedef ::std::basic_ostream<CharType, CharTraits> base_type;
0084 public:
0085
0086 basic_onullstream() : pbase_type(), base_type( &this->pbase_type::member ) {}
0087 };
0088
0089 #ifdef BOOST_MSVC
0090 # pragma warning(default: 4355)
0091 # pragma warning(pop)
0092 #endif
0093
0094 typedef basic_onullstream<char> onullstream;
0095 typedef basic_onullstream<wchar_t> wonullstream;
0096
0097 }
0098
0099
0100
0101 #include <boost/test/detail/enable_warnings.hpp>
0102
0103 #endif