On Mon, Jul 8, 2013 at 10:01 AM, Sid Sacek
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. Next thing you want is begin()/end() and friends and here we have a full fledged container interface. IIRC, shared_ptr was designed to be as close to raw pointers as possible, but not closer. 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. I would rather expect them to be based on Boost.Intrusive and provide the natural container interface with some extensions: shared_vector< int > svi; svi.push_back(10); shared_vector< int > svi2 = svi; // creates a ref-counted alias for svi shared_vector< int > svi3 = svi.clone(); // creates a deep copy of svi shared_map< string, string > smss; smss["aaa"] = "bbb"; shared_map< string, string > smss2 = smss; // also an alias shared_map< string, string > subtree = smss.subtree("aaa"); // creates an alias to the subtree etc. The extensions are a just a thought.