summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJaskamal Kainth <kainthjaskamal@gmail.com>2016-01-28 17:15:44 +0530
committerJaskamal Kainth <kainthjaskamal@gmail.com>2016-01-28 17:15:44 +0530
commit4a1a6857ce30f19f8c04dcca4571bb27f7dc36d0 (patch)
treed269ab5e08478f6e27921a7e23a3f7d1ae688526
parentc805148618f5b2679d6581ff41885abc7140fd4d (diff)
[C++/en] Tuple , updated
-rw-r--r--c++.html.markdown10
1 files changed, 5 insertions, 5 deletions
diff --git a/c++.html.markdown b/c++.html.markdown
index 594cf15f..ea6ef034 100644
--- a/c++.html.markdown
+++ b/c++.html.markdown
@@ -967,10 +967,10 @@ v.swap(vector<Foo>());
// 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;
const int maxL = 15;
-auto second = make_tuple( maxN , maxL ) ;
+auto second = make_tuple(maxN,maxL) ;
// printing elements of 'first' tuple
cout << get<0>(first) << " " << get<1>(first) << "\n"; //prints : 10 A
@@ -983,12 +983,12 @@ cout << get<0>(second) << " " << get<1>(second) << "\n"; // prints: 1000000000 1
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.
-tuple<int , char , double> third ( 11 ,'A' , 3.14141);
+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
@@ -996,7 +996,7 @@ cout << tuple_size < decltype(third) >::value << "\n"; // prints: 3
// tuple_cat concatenates the elements of all the tuples in the same order.
auto concatenated_tuple = tuple_cat( first, second ,third);
-// concatenated_tuple becomes = (10 , 'A' , 1e9 , 15 , 11 , 'A' , 3.14141 )
+// concatenated_tuple becomes = (10,'A',1e9,15,11,'A',3.14141)
cout << get<0>(concatenated_tuple) << "\n"; // prints: 10
cout << get<3>(concatenated_tuple) << "\n"; // prints: 15