Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-11-01 14:51:31


----- Original Message -----
From: "Howard Hinnant" <hinnant_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, November 01, 2000 1:40 PM
Subject: RE: [boost] Re: Shades, swap or whatever

> Gary Powell wrote on 11/1/2000 1:25 PM
>
> >That makes no sense.
>
> The language people just like to irritate us mortals. Did I mention that
> templates were added into the language on April 1? ;-)
>
> template<class T> class f{}; // #1
> template<> class f<int *> {}; // #2
> template<class T> class f<T *> {}; // #3
>
> #1 and #3 are overloads. #2 is a specialization of either #1 or #3
> depending upon order, or who you talk to. Overloads are chosen
> irrespective of specializations, then once an overload is chosen,
> specializations of that particular overload are considered... Or
> something like that. I'm just parroting what I've heard and may have
> goofed it up in the translation.

Well, considering that these are classes and not functions, I think
something got goofed up somewhere ;-)

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

#2 is really the /same/ /entity/ as #1. Think of it as a way of saying,
"when T is int* in template #1, this is the implementation. So the choice at
overload resolution time is between 1 and 3.

-Dave


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