Skip to content

Instantly share code, notes, and snippets.

@alexeiz
Created May 5, 2013 04:37
Show Gist options
  • Save alexeiz/5519730 to your computer and use it in GitHub Desktop.
Save alexeiz/5519730 to your computer and use it in GitHub Desktop.
Redirect cout to a null sink using boost::iostreams.
#include <boost/iostreams/stream_buffer.hpp>
#include <boost/iostreams/device/null.hpp>
#include <iostream>
namespace io = boost::iostreams;
int main()
{
io::stream_buffer<io::null_sink> null_buf{io::null_sink()};
std::cout.rdbuf(&null_buf);
std::cout << "some junk" << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment