I was going over C++0x. As i looked 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 these to make code look and feel consistant.
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.