Senthilvel Samatharman <Samatharman.Senthilvel@adcc.alcatel.be> wrote in
message news:3F5DDC7D.F96BDD20@adcc.alcatel.be...[color=blue]
> Dave Theese wrote:
>[color=green]
> > Hello all,
> >
> > I'm trying to get a grasp of the difference between specializing a[/color][/color]
function[color=blue][color=green]
> > template and overloading it. The example below has a primary template,[/color][/color]
a[color=blue][color=green]
> > specialization and an overload. Note that the overload is identical to[/color][/color]
the[color=blue][color=green]
> > specialization except, of course, for the missing "template <>".
> >
> > I don't know if my questions will be a bit too broad or not, but I[/color][/color]
thought[color=blue][color=green]
> > I'd give it shot... When is overloading preferable to specialization?[/color][/color]
When[color=blue][color=green]
> > is specialization preferable to overloading? What is the intended
> > conceptual difference between the two? Any other guidance on other[/color][/color]
things I[color=blue][color=green]
> > need to know but don't know enough yet to even ask?[/color]
>
> I had the same question sometime back and this is the reply from Bjarne
> Stroustrup....
>
> "For functions, you don't have to. Overloading will do. For classes, you[/color]
don't[color=blue]
> have an alternative. Note that when you specialize the specialzation[/color]
doesn't[color=blue]
> affect overload resolution rules, when you overload with a[/color]
non-specialization,[color=blue]
> overload resolution will prefer the non-specialization."[/color]
Vandevoordes & Josuttis' recent book "C++ Templates"
imo covers this and other template issues quite well.
I must admit it will take me at least a few passes through this
great book to absorb everything therein. :-)
http://www.josuttis.com/tmplbook/index.html
-Mike