Redirect debug output to null stream instead of std::cerr
问题 A software library that I am working with writes a lot of debug output to std::cerr , but redirects that output to a null stream if I tell it to be quiet. This is a simplified main.cpp that shows how the code tries to achieve this: #include <iostream> #include <fstream> #include <cassert> // The stream that debug output is sent to. By default // this points to std::cerr. std::ostream* debugStream(&std::cerr); // Throughout the library's codebase this function is called // to get the stream