Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Sid Sacek (ssacek_at_[hidden])
Date: 2013-07-08 04:22:22
Andrey Semashev wrote:
> > Now watch this:
> > int my_buffer_size = 1234;
> > auto buffer = boost::make_shared< unsigned char >( > my_buffer_size );
> > buffer[ index ] = something;
> > int cap = buffer.capacity();
> > Doesn't that feel the most natural ?
> I agree that the syntax is simpler but that functionality exceeds that of a pointer, IMHO.
I want to agree with you, only to make you happy, but I'm sorry, shared_ptr<T> does not
behave like a pointer at all. It behaves like an array. Check out the available member
functions. You cannot write code like this:
buffer-> ???? // what does this point to, I cannot figure it out ???
> If you want a container, use one. Containers with shared storage would be a nice addition
> to Boost, IMHO, but these should not abuse shared_ptr interface.
According to what you just wrote 'shared_ptr<T>' has already abused 'shared_ptr<>' and
all of the array features should be rolled back, or be put into another class altogether.
In all seriousness, I'm not trying to be a thorn in anybody's side here. All I'm saying
is that 'shared_ptr<T>' looks to me like it has come 99% of the way to being a full-blown
object-oriented shared-buffer. I'm saying, adding the capacity will simply bring that
concept closer to completion.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk