During development of my project in C++
I have a frequent need of debugging and I usually use this macro to do it
#define DBUG(a) {std::cout << #a << " : " << a << std::endl;};
But many times I need to do something like this
int a;
std :: string b;
double c;
...
...
DBG(a); DBG(b); DBG(c);
But ideally it might be possible to just write DBUG(a, b, c)
or DBG(a, b, c, d, e)
for more variables to achieve something like this. After some research this looked like a problem in meta-programming or more specifically code-generation, but because of my limited knowledge in these areas I could not find a way to go about it.
If possible I would like to solve this without using Boost or other external libraries, and using the features in C++98
although if it is not possible I'm willing to use C++11
.