mercredi 11 mars 2015

C++11 way to index tuple at runtime without using switch

I have a piece of c++11 code similar like below:



switch(var) {
1: dosomething(std::get<1>(tuple));
2: dosomething(std::get<2>(tuple));
...
}


Is there any way to remove this large switch ? Note that get<var> does not work because var is not constant, but I know var is in small range i.e. (0-20).


Note that the point here is to avoid using an array that causes an array lookup.


Aucun commentaire:

Enregistrer un commentaire