2012-05-05 08:15:15 -07:00
|
|
|
#include <tuple>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
// tuple-returning func
|
2012-08-30 08:33:31 -07:00
|
|
|
auto some_func() -> tuple<int, int> {
|
|
|
|
return make_tuple(4, 2);
|
|
|
|
}
|
2012-05-05 08:15:15 -07:00
|
|
|
|
2012-05-25 07:17:47 -07:00
|
|
|
int main() {
|
2012-08-30 08:33:31 -07:00
|
|
|
auto c = make_tuple(5, 4);
|
|
|
|
cout << get<0>(c) << endl;
|
|
|
|
|
|
|
|
int a = 0;
|
|
|
|
int b = 1;
|
|
|
|
tie(a, b) = make_tuple(b, a);
|
|
|
|
cout << a << endl;
|
|
|
|
cout << b << endl;
|
2012-05-05 08:15:15 -07:00
|
|
|
// get a,b from func ...
|
2012-08-30 08:33:31 -07:00
|
|
|
tie(a, b) = some_func();
|
|
|
|
cout << a << endl;
|
|
|
|
cout << b << endl;
|
2012-05-05 08:15:15 -07:00
|
|
|
}
|