|
Boost : |
Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2013-07-08 07:40:46
On Mon, Jul 8, 2013 at 3:28 PM, Jonathan Wakely
<jwakely.boost_at_[hidden]> wrote:
> On 8 July 2013 12:20, Andrey Semashev wrote:
>> On Mon, Jul 8, 2013 at 3:04 PM, Sid Sacek <ssacek_at_[hidden]> wrote:
>>>
>>> What I mean is, operator->() does not exist. How can it be a pointer when it is not possible to use pointer notation?
>>
>> In that case I'd consider this a bug.
>
> It's consistent with the interface of std::unique_ptr<T[]>.
>
> You can use p.get()->x instead of p->x if you really want to use that
> notation to access the first element only, but how often do you really
> want to access the first element of an array, and p[0] isn't just as
> natural?
I don't see anything wrong with accessing the array element with
operator->. This may be limited to the first element only in case of
unique_ptr, but shared_ptr supports pointer aliasing, so it can refer
to any element within the array. But even in case of unique_ptr I
would still provide operator-> for sake of consistency.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk