Why can't I do tupleVar.get (3) or .get <3> ()?

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.
+3
source share
1 answer
+6

Source: https://habr.com/ru/post/1757355/


All Articles