Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-01-27 13:32:27


"Daniel Wallin" <dalwan01_at_[hidden]> wrote in message
news:4016A5B7.3010908_at_student.umu.se...
> Jonathan Turkanis wrote:
> > "Peter Dimov" <pdimov_at_[hidden]> wrote in messag:

> >
> > If pointers to objects and pointers to arrays need different
> > treatment, one can use:
> >
> > template<class X> void f(S_ptr<X> px);
> > template<class X> void f(S_ptr<X[]> px);
>
> The problem is that you don't always want to have both overloads and
in
> those cases a compiler error is very unhelpful. I can't come up with
> very good examples, at least not right now. But in general,
disabling an
> overload is far better than failing to compile. Maybe Peter has some
use
> case where this applies?
>

I almost agree. The reason that disabling overloads is better than
forcing compiler errors is that you often want to allow other
overloads to match. Here, if you want another overload -- or if
someone else want to write one later -- no problem. If you don't, why
not? Either (i) the same code works for smart pointers to objects and
smart pointers to arrays, in which case there's no problem, or (ii)
the code is specific to one case or the other, so a compiler error
indicates a misuse of the function, which seems appropriate.

Regards,
Jonathan


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