summaryrefslogtreecommitdiffhomepage
path: root/c++.html.markdown
diff options
context:
space:
mode:
authorJaskamal Kainth <kainthjaskamal@gmail.com>2016-01-28 15:26:35 +0530
committerJaskamal Kainth <kainthjaskamal@gmail.com>2016-01-28 15:26:35 +0530
commitc805148618f5b2679d6581ff41885abc7140fd4d (patch)
treeed953f3d52175d908a03b7587d670b94f982df94 /c++.html.markdown
parent32f18cd992b5b6988a3b37eaa533f8215d83fe2e (diff)
[C++/en] Tuples in C++
Diffstat (limited to 'c++.html.markdown')
-rw-r--r--c++.html.markdown13
1 files changed, 6 insertions, 7 deletions
diff --git a/c++.html.markdown b/c++.html.markdown
index b8ab656c..594cf15f 100644
--- a/c++.html.markdown
+++ b/c++.html.markdown
@@ -966,25 +966,24 @@ v.swap(vector<Foo>());
// its elements are accessed by their order in the tuple.
// We start with constructing a tuple.
-//
// Packing values into tuple
-auto first = make_tuple ( 10 , 'A' ) ;
+auto first = make_tuple( 10 , 'A' ) ;
const int maxN = 1e9;
-int maxL = 15;
-auto second = make_tuple ( maxN , maxL ) ;
+const int maxL = 15;
+auto second = make_tuple( maxN , maxL ) ;
// printing elements of 'first' tuple
cout << get<0>(first) << " " << get<1>(first) << "\n"; //prints : 10 A
// printing elements of 'second' tuple
-cout << get<0>(second)<< " " << get<1>(second) << "\n"; // prints: 1000000000 15
+cout << get<0>(second) << " " << get<1>(second) << "\n"; // prints: 1000000000 15
// Unpacking tuple into variables
int first_int;
char first_char;
-tie (first_int , first_char ) = first;
+tie(first_int , first_char ) = first;
cout << first_int << " " << first_char << "\n"; // prints : 10 A
// We can also create tuple like this.
@@ -992,7 +991,7 @@ cout << first_int << " " << first_char << "\n"; // prints : 10 A
tuple<int , char , double> third ( 11 ,'A' , 3.14141);
// tuple_size returns number of elements in a tuple (as a constexpr)
-cout << tuple_size< decltype(third)>::value << "\n"; // prints: 3
+cout << tuple_size < decltype(third) >::value << "\n"; // prints: 3
// tuple_cat concatenates the elements of all the tuples in the same order.