I iterated over C ++ 0x. Since I was looking at tuple , I saw this example. Why do I need to do get<3>(var)? Why can't I do var.get(index)or var.get<index>()? I prefer them to make the code understandable and understandable.
typedef tuple< int, double, long &, const char * > test_tuple ;
long lengthy = 12 ;
test_tuple proof( 18, 6.5, lengthy, "Ciao!" ) ;
lengthy = get<0>(proof) ; // Assign to 'lengthy' the value 18.
get<3>(proof) = " Beautiful!" ; // Modify the tupleβs fourth element.
user34537
source
share