Boost logo

Boost :

From: Philippe A. Bouchard (philippeb_at_[hidden])
Date: 2002-07-30 16:19:27


> > [...]
> > ptr<Derived> pD = new Derived;
> > ptr<Derived, X> pX = new X;
> > ptr<Derived, Y> pY = new Y;
> >
> > pX = pD; // Won't work
> > pY = pD; // Won't work
> > [...]
>
> Of course, this syntax is clumsier than existing pointers, and also less
> powerful. For instance, you may have code that knows about X or Y,
> but not about anything derived from X or Y. Your proposal requires
> such code to know about all possible derivatives in order to work
> properly, which is a fairly restrictive requirement.

 Y * pY = new Derived;
 delete pY;

Will result in a segmentation fault. It is already not handled properly
with raw pointers. ptr<Derived, Y> is just a 'feature'.

Philippe A. Bouchard


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