|
Boost : |
Subject: Re: [boost] [shared_array] Why not in C++11 ?
From: Glen Fernandes (glen.fernandes_at_[hidden])
Date: 2013-07-08 02:26:29
Sid Sacek 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 can see why you desire this. One concern is that
boost::shared_ptr<T[]> is usable without boost::make_shared. With
boost::make_shared, yes, in my implementation the size is stored
somewhere and changing the machinery could possibly surface that
through boost::shared_ptr's interface. But what happens when
boost::shared_ptr<T[]> is used with operator new[]? The size is not
stored in that case.
You mentioned in an earlier mail that you would prefer that size()
return a value like -1 in such a case. That also feels very strange to
me; i.e. returning a size_t but reserving a value like -1 to indicate
unknown size.
Glen
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk