I am still at basic understanding of meta-programming.
I am struggling to understand the difference, if any, of using the int type or the size_t type when using this type as a template type.
I understand the difference between both in standard c++ programming as explained here What's the difference between size_t and int in C++?
Then when reading questions related to some template tricks, it seems that people tends to use them undifferently. For example on this one How can I get the index of a type in a variadic class template? Barry is using std::integral_constant instantiated with size_t type
In this question: C++11 Tagged Tuple ecatmur provides an answer where its index helpers use int type instance of std::integral.
Modify one with the other seems to have no impact for what I have tested. Those template specialization being recursive, I presume anyway that in practice compiler would collapse if the Index N was too big.
Is choosing int or size_t in this specific context only a question of coding style ?
Aucun commentaire:
Enregistrer un commentaire