final tuple example

This commit is contained in:
Stephen M. McQuay 2012-08-30 09:33:31 -06:00
parent 46094f5196
commit a03ea7232b

View File

@ -5,9 +5,21 @@ using namespace std;
// tuple-returning func // tuple-returning func
auto some_func() -> tuple<int, int> {
return make_tuple(4, 2);
}
int main() { int main() {
// make a tuple, get a value from it (silly <i> syntax) auto c = make_tuple(5, 4);
// swap a and b cout << get<0>(c) << endl;
int a = 0;
int b = 1;
tie(a, b) = make_tuple(b, a);
cout << a << endl;
cout << b << endl;
// get a,b from func ... // get a,b from func ...
tie(a, b) = some_func();
cout << a << endl;
cout << b << endl;
} }