fork download
  1. #include <iostream>
  2. #include <tuple>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7. tuple<int, double, const char *> f1()
  8. {
  9. return make_tuple(10, 22.33, "ABC");
  10. }
  11.  
  12. pair<int, int> f2()
  13. {
  14. return make_pair(123, 456);
  15. }
  16.  
  17. int main() {
  18. int x;
  19. double y;
  20. const char *z;
  21. tie(x, y, z) = f1();
  22.  
  23. cout << x << "," << y << "," << z << endl;
  24.  
  25. tuple_element<0, decltype(f2())>::type a;
  26. tuple_element<1, decltype(f2())>::type b;
  27. tie(a, b) = f2();
  28. cout << a << "," << b << endl;
  29. }
  30.  
Success #stdin #stdout 0s 2928KB
stdin
Standard input is empty
stdout
10,22.33,ABC
123,456