fork(2) download
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. #define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 5,4,3,2,1))
  5. #define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
  6. #define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,N,...) N
  7.  
  8. #define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
  9. #define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
  10. #define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
  11. #define macro_dispatcher___(macro, nargs) macro ## nargs
  12.  
  13. #define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
  14.  
  15. #define DBN1(a) cerr<<#a<<"="<<(a)<<"\n"
  16. #define DBN2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
  17. #define DBN3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
  18. #define DBN4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
  19. // ...
  20.  
  21.  
  22. int main()
  23. {
  24. int x = 5, y = 10;
  25.  
  26. DBN(x, y, x*y+2);
  27. DBN(x+1, y/x);
  28.  
  29. return 0;
  30. }
  31.  
  32.  
  33.  
  34.  
Success #stdin #stdout #stderr 0s 3292KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
x=5, y=10, x*y+2=52
x+1=6, y/x=2