I'm looking for a std::ostream
implementation that acts like /dev/null
. It would just ignore anything that is streamed to it. Does such a thing exist in the standard libraries or Boost? Or do I have to roll my own?
If you have boost, then there's a null ostream & istream implementation available in boost/iostreams/device/null.hpp . The gist of it:
#include "boost/iostreams/stream.hpp"
#include "boost/iostreams/device/null.hpp"
...
boost::iostreams::stream< boost::iostreams::null_sink > nullOstream( ( boost::iostreams::null_sink() ) );
...