|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-11-01 13:51:08
> > Presumably this arises from the interaction with overloading.
> > Something like:
> >
> > template <class T> void f(T); // #1
> > template <class T> void f(T*); // #2
> > template <> void f<int*>(int*); // specialising #1 or #2?
>
> This one's easy. It's a full specialization for #2 (as I wrote in an
earlier
> message, it is order-dependent).
You got me worried.
#include <iostream>
template <class T> void f(T) { std::cout << 1 << '\n'; } // #1
template <class T> void f(T*) { std::cout << 2 << '\n'; } // #2
template <> void f<int*>(int*) { std::cout << 3 << '\n'; } //
specialising #1 or #2?
int main()
{
int * p = 0;
f(p);
return 0;
}
prints 2, as expected, on bcc 5.5.1 and g++ 2.95.2. #3 does not
specialize #2.
-- 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