G
George2
Hello everyone,
About Template Partial Specialization,
http://www.cprogramming.com/tutorial/template_specialization.html
sometimes in real case like below,
http://www.sgi.com/tech/stl/iterator_traits.html
there will be two definitions at the same time,
In theory, compiler will match the latter one with first priority
compared with the 1st one.
My question is, I tihnk for basic data types it is easy to match,
example,
when we pass Foo <int*>, the latter one is matched and T is int. But
for arbitrary data types, like used data types, how could compiler
judge whether a type is pointer (when the latter template class should
be matched) or not a pointer (when the first template class should be
matched).
thanks in advance,
George
About Template Partial Specialization,
http://www.cprogramming.com/tutorial/template_specialization.html
sometimes in real case like below,
http://www.sgi.com/tech/stl/iterator_traits.html
there will be two definitions at the same time,
Code:
template <typename T>
class Foo {
}
template <typename T>
class Foo <T *>
{
}
In theory, compiler will match the latter one with first priority
compared with the 1st one.
My question is, I tihnk for basic data types it is easy to match,
example,
when we pass Foo <int*>, the latter one is matched and T is int. But
for arbitrary data types, like used data types, how could compiler
judge whether a type is pointer (when the latter template class should
be matched) or not a pointer (when the first template class should be
matched).
thanks in advance,
George