template <int T> struct int2type{};
template<int I>
void func( int2type<I> )
{
printf("int_val: %i\n", I);
}
int main(int argc, char *argv[])
{
func( int2type<10>() );
}
Of course it prints 10.
I have some basic idea of how templates and type deduction works, but i can't understand this code. What is the magic behind I? How we know I from int2type instance passed to func?
Aucun commentaire:
Enregistrer un commentaire