Advertisement
Sumss

c++ framework

Dec 7th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. /*
  2. * Starting out a new project? add these simple help macros and functions to make you life easier!
  3. */
  4.  
  5. =========================================================================
  6. Easy cout for one variable
  7. =========================================================================
  8. #define what_is(arg) std::cout << #arg << ": "<< arg << std::endl;
  9. int x = 1;
  10. what_is(x); //x: 1
  11.  
  12.  
  13.  
  14. =========================================================================
  15. Easy full cout for one variable
  16. =========================================================================
  17. #define what_is_full(arg) std::cout << __FILE__ << " " << __LINE__  << ": "<< #arg << "=" << arg << std::endl;
  18. int y = 1;
  19. what_is(y); //"FILE LINE: x=1
  20.  
  21.  
  22.  
  23. =========================================================================
  24. Easy cout for one or more variables
  25. =========================================================================
  26. template<typename... T>
  27. void what_is_mult(T&&... args)
  28. {
  29.   ((std::cout << args), ...);
  30. }
  31. int x = 1;
  32. int y = 2;
  33. what_is_mult("\n", "x: ", x, "\n", "y: ", y); // x: 1
  34.                                               // y: 2
  35.  
  36.  
  37.  
  38. =========================================================================
  39. Debug mode
  40. =========================================================================
  41. #define DEBUG true // or false
  42. #if DEBUG == true //only do this if we are in DEBUG mode
  43.  //Do something if we are in DEBUG mode
  44. #endif
  45.  
  46.  
  47.  
  48. =========================================================================
  49.  
  50. =========================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement