Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #define UNPACK_PAIR(V1, V2, PAIR)
  2. auto& V1 = PAIR.first;
  3. auto& V2 = PAIR.second;
  4.  
  5. USE_FOO(one, two, x);
  6.  
  7. USE_FOO(one, two, expensive_computation());
  8.  
  9. #define UNPACK_PAIR_A(V1, V2, PAIR)
  10. auto tmp = PAIR;
  11. auto& V1 = tmp.first;
  12. auto& V2 = tmp.second;
  13.  
  14. #define UNPACK_PAIR_R(V1, V2, PAIR)
  15. auto& tmp = PAIR;
  16. auto& V1 = tmp.first;
  17. auto& V2 = tmp.second;
  18.  
  19. #define UNPACK_PAIR_CR(V1, V2, PAIR)
  20. const auto& tmp = PAIR;
  21. auto& V1 = tmp.first;
  22. auto& V2 = tmp.second;
  23.  
  24. #define UNPACK_PAIR_RR(V1, V2, PAIR)
  25. auto&& tmp = PAIR;
  26. auto& V1 = tmp.first;
  27. auto& V2 = tmp.second;
  28.  
  29. #define UNPACK_PAIR_RR(V1, V2, PAIR)
  30. auto&& tmp = std::move(PAIR);
  31. auto& V1 = tmp.first;
  32. auto& V2 = tmp.second;
  33.  
  34. #define UNPACK_PAIR_RR(V1, V2, PAIR)
  35. auto&& tmp = std::forward<decltype(PAIR)>(PAIR);
  36. auto& V1 = tmp.first;
  37. auto& V2 = tmp.second;
  38.  
  39. auto p = std::make_pair(2, 3);
  40. int x, y;
  41. std::tie(x, y) = p;
  42.  
  43. auto p = std::make_pair(2, 3);
  44. int& x = p.first;
  45. int& y = p.second;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement