Is there a way to create an ostream instance which basically doesn't do anything and doesn't evaluate code ?
For example:
#include <iostream>
#if defined(DEBUG)
#define LOG std::cout
#else
#define LOG std::ostream {nullptr}
#endif
#if defined(DEBUG)
std::string MyFunc()
{
return "mystring";
}
#endif
int main()
{
LOG << MyFunc() << std::endl;
return 0;
}
If the flag "DEBUG" is set, the compilation works. Otherwise, I have the following error :
error: 'MyFunc' was not declared in this scope
Is it possible to skip code after null stream operator?
I found the following topic Standard no-op output stream