cpp11/tuple.cc

24 lines
422 B
C++
Raw Normal View History

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