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 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 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