Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-01-11 09:36:48


From: "David Abrahams" <david.abrahams_at_[hidden]>
> From: "Peter Dimov" <pdimov_at_[hidden]>
> > shared_array in
> >
> > http://groups.yahoo.com/group/boost/files/smart_ptr_3.zip
> >
> > can be trivially extended to support it by adding
> >
> > shared_array & operator+= (std::ptrdiff_t i)
> > {
> > px += i;
> > return *this;
> > }
>
> I dunno; what about the destructor?
>
> > Of course the BOOST_ASSERT(i >= 0); in operator[] will need to be
removed.
>
> you can replace it with (lower) bounds checking if the array's base is
also
> held in the count object. You need something like that in order support
> addition anyway.

The array base is held internally in shared_count, that's why there are no
destruction problems with the above. But it's not accessible since
shared_count helds a counted_base* which only provides add_ref/release.

--
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