Subject: Re: [boost] [smart_ptr] scoped_array / shared_array (size_t) constructor
From: Richard Hadsell (hadsell_at_[hidden])
Date: 2011-11-01 11:29:54
On 10/31/2011 07:19 PM, Olaf van der Spek wrote:
> On Mon, Oct 31, 2011 at 11:52 PM, Richard Hadsell
> <hadsell_at_[hidden]> wrote:
>> Yes, it matters. You can test a scoped_array to see whether anything is
>> allocated. You can't determine that its size is 0.
> Don't you keep the size somewhere else? The array seems kinda useless
> when you don't know the size.
Sure, but it's a lot easier to just test the pointer. You can replace a plain old pointer with a scoped_ptr or scoped_array without changing any code, except where the object or array is allocated and deleted.
If I replaced a pointer to an array with a std::vector, the code would be entirely different, and it would take up more memory. If I had tens of thousands of these pointers (which I do), I would definitely stick with the current scoped_array and adamantly
protest any suggestion that would increase the memory footprint (as I once did a while ago).
-- Dick Hadsell 203-992-6320 Fax: 203-992-6001 Reply-to: hadsell_at_[hidden] Blue Sky Studioshttp://www.blueskystudios.com 1 American Lane, Greenwich, CT 06831-2560 Follow Blue Sky Studios on Facebook <http://www.facebook.com/BlueSkyStudios> and Twitter <http://twitter.com/#%21/blueskystudios>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk