1 Nov 2011 00:19
Re: [smart_ptr] scoped_array / shared_array (size_t) constructor
Olaf van der Spek <ml <at> vdspek.org>
2011-10-31 23:19:38 GMT
2011-10-31 23:19:38 GMT
On Mon, Oct 31, 2011 at 11:52 PM, Richard Hadsell <hadsell <at> blueskystudios.com> wrote: > On 10/31/2011 05:26 PM, Olaf van der Spek wrote: >> >> On Mon, Oct 31, 2011 at 9:51 PM, Andrey Semashev >> <andrey.semashev <at> gmail.com> wrote: >>> >>> 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? > > 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. > If you want to implement this feature, you would have to advertise this as a > change in the interface, not just a new feature, because, as people have > pointed out, 0 would map to the size constructor rather than the default > pointer. Yeah, that's a problem. Olaf _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
RSS Feed