From a03ea7232b1bfdb98aff550ffff4b8b51f00fdec Mon Sep 17 00:00:00 2001 From: "Stephen M. McQuay" Date: Thu, 30 Aug 2012 09:33:31 -0600 Subject: [PATCH] final tuple example --- tuple.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tuple.cc b/tuple.cc index f64cf2d..5b79e35 100644 --- a/tuple.cc +++ b/tuple.cc @@ -5,9 +5,21 @@ using namespace std; // tuple-returning func +auto some_func() -> tuple { + return make_tuple(4, 2); +} int main() { - // make a tuple, get a value from it (silly syntax) - // swap a and b + 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; // get a,b from func ... + tie(a, b) = some_func(); + cout << a << endl; + cout << b << endl; }