Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-11 09:08:24


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
of enabling pointer arithmetic for shared_array somewhat
> questionable, but...
>
> 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.

-Dave


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