Boost logo

Boost :

Subject: Re: [boost] [smart-ptr][containers] type of the operator[] index
From: Rhys Ulerich (rhys.ulerich_at_[hidden])
Date: 2011-12-04 17:11:18


>> Scoped_array can not take a pointer in the middle of the allocated array
>> as its role is to delete it.
>
> Exactly.

True for scoped_array. As Olaf pointed out, it would be possible to
have a custom deleter for shared_array that would allow shared_array
to point to the middle of an allocation. Then it seems reasonable to
have shared_array::operator[] take a ptrdiff_t. It'd be weird to have
shared_array and scoped_array take different types for operator[].
ptrdiff_t for both seems fine to me and size_t is demonstrably wrong
for shared_array in at least one (very goofy) use case.

- Rhys


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