// nulstream.h // #if !defined( NULSTREAM__H) #define NULSTREAM__H #include #include "nulstream_failbit.h" #include "nulstream_ignoreoutput.h" template< class char_type, class traits_type = std::char_traits< char_type>, class underlying_stream_type = basic_nulstream_failbit< char_type, traits_type> > class basic_nulstream : public underlying_stream_type { private: typedef basic_nulstream< char_type, traits_type, underlying_stream_type> this_class; typedef std::basic_ostream< char_type, traits_type> ostream_type; // IO Manipulator functions typedef std::ios_base & (*iosbase_func)( std::ios_base&); typedef std::basic_ios< char_type, traits_type> & (*ios_func)( std::basic_ios< char_type, traits_type> &); typedef std::basic_ostream< char_type, traits_type> & (*ostream_func)( std::basic_ostream< char_type, traits_type> &); public: // ignore everything written to it! template< class type> this_class& operator<< ( const type & val) { return *this; } this_class& operator<< ( iosbase_func) { return *this; } this_class& operator<< ( ios_func) { return *this; } this_class& operator<< ( ostream_func) { return *this; } ostream_type& put(char_type c) { return *this; } ostream_type& write(const char_type* , std::streamsize ) { return *this; } ostream_type& flush() { return *this; } }; typedef basic_nulstream< char> nulstream; typedef basic_nulstream< wchar_t> wnulstream; typedef basic_nulstream< char, std::char_traits< char>, nulstream_ignoreoutput> nulstream_ignore; typedef basic_nulstream< wchar_t, std::char_traits< wchar_t>, nulstream_ignoreoutput> wnulstream_ignore; #endif