I want to define like this:
#define log(x) \
#if (x) \
cout << "\n" << x \
#else \
cout \
Example:
log() << abc
~
cout << abc
and
log(name) << abc
~
cout << "\n" << name << abc
It similar the problem in the question in here C preprocessor macro specialisation based on an argument
I want to use define because actually, I use cout for people can easily understand my intent.
I doing the Qt and need log using QLoggingCategory
QLoggingCategory category("MyNameSpace");
And when need log, I need to use the syntax
qCDebug(category) << something_need_log
Here, qCDebug(category) like the cout in my question.