|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-01-26 12:42:38
From: "David Abrahams" <abrahams_at_[hidden]>
[about the equivalence of class/function template partial spec]
> Wow, that's a terriffic simplification if it works -- like proving
Fermat's
> theorem in terms of hyperbolic geometry (but far easier to check) ;-)
> I'd love to hear from Peter Dimov whether he believes this fits the bill.
Yes... and no.
This is a good point, one I'm trying to get across. Once you have the
partial specializations defined, there is absolutely no difference between
the class and function templates in respect to specializations.
The current compilers when instantiating a class template do something like
* find the primary template and all specializations;
* determine the correct specialization to use;
* create an instance based on the specialization (or the primary template,
if no specialization matches.)
The _exact same_ procedure may be applied to function templates, and it all
will "just work."
But, there is also the question of getting the specializations defined (or
declared.)
There is a difference between classes and functions in this area because a
class template is unique, whereas a function template may be overloaded, so
there's the additional step of determining which function template, if any,
is being specialized.
This step is not that difficult, but it does add some complexity over the
class template case.
Then there are the psychological reasons. Surprisingly few people
distinguish overloads from specializations, and adding partial
specializations is not going to help. :-) On the other hand, people
routinely call overloads "partial specializations" without knowing that this
thing doesn't exist and use this lack of knowledge as an excuse to add to
std::, so perhaps the feature does belong to C++, after all. Many people are
expecting it to be in the language and are surprised when they don't find
it.
-- 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