
On Mon, Oct 31, 2011 at 9:51 PM, Andrey Semashev <andrey.semashev@gmail.com> 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?
FWIW, I would rather prefer make_scoped_array and make_shared_array function templates for this purpose, much like make_shared we already have. Of course, scoped_array would have to support move semantics in order to do that. In conjunction with auto keyword, one would not have to duplicate the array element type.
Not everybody can use C++11 yet... -- Olaf