Subject: Re: [boost] [smart_ptr] scoped_array / shared_array (size_t) constructor
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2011-10-31 17:41:09
On Monday, October 31, 2011 22:26:16 Olaf van der Spek wrote:
> On Mon, Oct 31, 2011 at 9:51 PM, Andrey Semashev
> <andrey.semashev_at_[hidden]> wrote:
> >> Is (almost) nobody using scoped/shared_array?
> > I'm using it, from time to time. Frankly, I'm not sure there's much
> > value in the suggested improvement. Smart pointers are not containers,
> > so there's no need to follow the interface, especially considering
> > ambiguities like boost::scoped_array<unsigned char> A(0); (is 0 a null
> > pointer or a zero size of the array here?). Zero sized arrays are quite
> > valid when dynamically allocated (the allocation result is not NULL in
> > this case), so you can't always initialize the pointer to NULL in this
> > case.
> Why not? Does the pointer matter if the size is 0?
It does, if it must not be NULL or NULL is a reserved value. In any case, the
smart pointer should not alter semantics of the basic language constructs.
This would be most counter-intuitive, IMHO.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk