Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. int func {
  2. int V1, V2, ... , Vn;
  3.  
  4. #define cnt 0
  5. // a block of code: some operations with V1, ... , Vn
  6. #undef cnt
  7.  
  8. #define cnt 1
  9. // the same block of code
  10. #undef cnt
  11. }
  12.  
  13. struct Nested {
  14. __forceinline void block(const int cnt) {
  15. // block of code
  16. };
  17. };
  18.  
  19. struct func_impl
  20. {
  21. int V1, V2, ..., Vn;
  22. int res;
  23.  
  24. template <int cnt>
  25. void blockOfCode() {
  26. ...
  27. }
  28. };
  29.  
  30. int func()
  31. {
  32. func_impl f;
  33. f.blockOfCode<0>();
  34. f.blockOfCode<1>();
  35. return f;
  36. }
  37.  
  38. int var[2];
  39. var[cnt] = ...;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement