I saw other stack overflow messages that strongly prevent the operator from overloading the comma. I was sent a request to migrate Github with an overload of the comma operator, which looked something like this:
class Mylogger { public: template <typename T> Mylogger & operator,(const T & val) { std::cout << val; return * this; } }; #define Log(level,args...) \ do { Mylogger logv; logv,level, ":", ##args; } while (0)
Then you can use it as follows:
Log(2, "INFO: setting variable \", 1, "\"\n");
Can someone explain why this is a good or bad use case?
source share