Is it possible to write a macro which can take in a variable number of arguments and expands like this :
quickdebug(a) -> cout << #a ": " << a;
quickdebug(a,b) -> cout << #a ": " << a << #b ": "<< b;
etc
If not, is it possible for me to at least print all the arguments without giving format strings. e.g
quickdebug2(a) -> cout << a ;
quickdebug2(a,b) -> cout << a << " " << b ;
etc
For example in java I can write a function which provides me similar functionality:
void debug(Object...args)
{
System.out.println(Arrays.deepToString(args));
}
By using a class that overrides , operator:
You can write for instance:
This can then be wrapped with a preprocessor macro:
So you can write:
It would be easy to add f.i. separator strings to be used between arguments.
Edit: I just added a default space as separator string.