Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] scoped_array / shared_array (size_t) constructor
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-11-01 12:00:57


On Tue, Nov 1, 2011 at 4:29 PM, Richard Hadsell
<hadsell_at_[hidden]> wrote:
>> 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.

Actually, what is the problem?
Do you use (NULL) or (0) instead of just () (for construction).

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

This proposal does not change the footprint, does it?

-- 
Olaf

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk