fork(2) download
  1. #include <iostream>
  2. #include <tuple>
  3. using namespace std;
  4.  
  5. struct Empty {};
  6.  
  7. template <class T>
  8. auto print_mem(const T& obj)
  9. {
  10. cout << &obj << " - " << (&obj + 1) << " (" << sizeof(obj) << ")" << endl;
  11. }
  12.  
  13.  
  14. int main() {
  15. std::tuple<int> t_i;
  16. std::tuple<Empty> t_e;
  17. std::tuple<int, Empty, Empty> t_iee;
  18. std::tuple<Empty, Empty, int> t_eei;
  19. std::tuple<int, Empty, Empty, int> t_ieei;
  20.  
  21. cout << "std::tuple<int>" << endl;
  22. print_mem(t_i);
  23. cout << endl;
  24.  
  25. cout << "std::tuple<Empty>" << endl;
  26. print_mem(t_e);
  27. cout << endl;
  28.  
  29. cout << "std::tuple<int, Empty, Empty" << endl;
  30. print_mem(t_iee);
  31. print_mem(std::get<0>(t_iee));
  32. print_mem(std::get<1>(t_iee));
  33. print_mem(std::get<2>(t_iee));
  34. cout << endl;
  35.  
  36. cout << "std::tuple<Empty, Empty, int>" << endl;
  37. print_mem(t_eei);
  38. print_mem(std::get<0>(t_eei));
  39. print_mem(std::get<1>(t_eei));
  40. print_mem(std::get<2>(t_eei));
  41. cout << endl;
  42.  
  43. cout << "std::tuple<int, Empty, Empty, int>" << endl;
  44. print_mem(t_ieei);
  45. print_mem(std::get<0>(t_ieei));
  46. print_mem(std::get<1>(t_ieei));
  47. print_mem(std::get<2>(t_ieei));
  48. print_mem(std::get<3>(t_ieei));
  49. cout << endl;
  50. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
std::tuple<int>
0xff83ce64 - 0xff83ce68 (4)

std::tuple<Empty>
0xff83ce63 - 0xff83ce64 (1)

std::tuple<int, Empty, Empty
0xff83ce68 - 0xff83ce6c (4)
0xff83ce68 - 0xff83ce6c (4)
0xff83ce69 - 0xff83ce6a (1)
0xff83ce68 - 0xff83ce69 (1)

std::tuple<Empty, Empty, int>
0xff83ce6c - 0xff83ce74 (8)
0xff83ce70 - 0xff83ce71 (1)
0xff83ce6c - 0xff83ce6d (1)
0xff83ce6c - 0xff83ce70 (4)

std::tuple<int, Empty, Empty, int>
0xff83ce74 - 0xff83ce80 (12)
0xff83ce7c - 0xff83ce80 (4)
0xff83ce78 - 0xff83ce79 (1)
0xff83ce74 - 0xff83ce75 (1)
0xff83ce74 - 0xff83ce78 (4)