Boost logo

Boost :

From: Schoenborn, Oliver (Oliver.Schoenborn_at_[hidden])
Date: 2002-10-03 15:34:29


> No, that wont work. That would still require it's base to be
> copied--the same copy that occurs already.

It works because I've done it with my own "smart" pointers.
Oliver

> "Schoenborn, Oliver" <Oliver.Schoenborn_at_[hidden]> wrote in message
> news:35C5DD9F60FED21192B00004ACA6E6C70151C87D_at_nrclonex1.imti.nrc.ca...
> > > >
> > > I haven't looked real close, but doesn't the subsection titled
> > > "Smart Pointers and const" in Item 28 of Scott Meyers
> > > _More Effective C++_ contain a solution to this problem?
> > > Basically, it describes SmartPtr<T> derived from
> > > SmartPtrToConst<T> and SmartPtrToConst<T> containing
> > > a union of const and non-const pointers to T. Unfortunately,
> > > this would require changing shared_ptr.
> >
> > Another option is to have shared_ptr<T> inherit non-publicly from
> > shared_ptr<const T>, with a method to get a reference to the base. This
> > requires a little bit more maintenance of code since pretty much all of
> > the methods of the derived have to be forwarded to the base,
> > but it's not excruciating either. It avoids the copy construction too.


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