Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-11-01 14:02:02


> That makes no sense.
> template<class T> class f{}; // #1
> template<> class f<int *> {}; // #2
> template<class T> class f<T *> {}; // #3
>
> for f<int *> isn't #2 more specialized than #3?

Yes.

> And if
> it works this way for classes, why wouldn't it work that
> way for functions?

Because the above are all specializations, #2 is explicit, #3 is
partial; there is only one primary template, #1.

For functions we don't have partial specializations, so in the example

template<class T> void f(T); // #1
template<> void f<int*>(int*); // #2
template<class T> void f(T*); // #3

#3 is an overload of #1, not a specialization... which means that we
have two primary templates here, #1 and #3.

template<class T> void f<T*>(T*); would be the partial specialization
equivalent to your #3 above, if it were legal.

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk