Advertisement
tinyevil

Untitled

Dec 29th, 2018
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <cstdio>
  2. #include <functional>
  3.  
  4.  
  5. #if defined(STDFUNC)
  6.     void foo(const std::function<int()>& fn);
  7.     #define XXX foo([&]() -> int { return __COUNTER__ + x; });
  8. #else
  9.     void foo(void*, int(*fn)(void*));
  10.     #define XXX \
  11.         { \
  12.             auto fn = [&]() mutable -> int { \
  13.                 return __COUNTER__ + x; \
  14.             }; \
  15.             foo((void*)&fn, [](void* ud)->int{ \
  16.                 auto f = (decltype(fn)*)ud;  \
  17.                 return (*f)();  \
  18.             }); \
  19.         }
  20. #endif
  21.    
  22. #define YYY XXX;XXX;XXX;XXX;XXX;
  23. #define ZZZ YYY;YYY;YYY;YYY;YYY;
  24.  
  25.  
  26. void bar(int x){
  27.     ZZZ;
  28.     ZZZ;
  29.     ZZZ;
  30.     ZZZ;
  31.     ZZZ;
  32.     ZZZ;
  33.     ZZZ;
  34.     ZZZ;
  35.     ZZZ;
  36.     ZZZ;
  37.     ZZZ;
  38.     ZZZ;
  39.     ZZZ;
  40.     ZZZ;
  41.     ZZZ;
  42.     ZZZ;
  43.     ZZZ;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement