Boost logo

Boost :

Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Sid Sacek (ssacek_at_[hidden])
Date: 2013-07-08 07:04:36


Andrey Semashev and Robert Stewart wrote:

> >>> The buffer object no longer behaves like a regular shared_ptr<>, but behaves very
> >>> much like an array, and for all intents and purposes, it is an array, it is a buffer!
> >>> What I mean is, it is not a pointer anymore, and you can no longer do this:
> >>>
> >>> buffer-> ???? // what can the pointer operator be used for ????
> >>
> >> The operator-> would work like with any raw pointer - it would return a pointer to the first element of the array.
> >
> > His point is that, without at least knowing the capacity, code called with a shared_ptr<T[]> cannot use it because the extent is > unknown.
>
> You mean that the pointer may refer to a zero-sized array? Yes, that is UB, just as well as with the raw pointers.

What I mean is, operator->() does not exist. How can it be a pointer when it is not possible to use pointer notation?

        shared_ptr< char[] > buffer;
        buffer-> // pointer operation does not exist
        buffer[ n ] = m; // array indexing does exist

Since you can't use pointer notation, it is not a pointer.

These objects are arrays, plain and simple.

-Sid Sacek


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