Boost logo

Boost :

Subject: Re: [boost] make_shared_array
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2012-11-01 13:04:34

Hi Peter & Glen,

On Thu, Nov 1, 2012 at 6:07 AM, Peter Dimov <lists_at_[hidden]> wrote:
> It makes almost no sense to have a function called make_shared_array that
> does not, in fact, make a shared_array. On the other hand, Glen posits that
> some people may prefer to use shared_ptr instead of shared_array in their
> code for various reasons, one of which is that shared_array's default
> constructor can throw.

I agree that make_shared_array should return a shared_array. I would
much rather see shared_array improved to allow such an allocation
strategy -- I patch my local copy to have an aliasing constructor & an
implicit conversion to const. A non-throwing default constructor
would be very welcome too.

I don't like the idea of returning shared_ptr due to concerns with
implicit conversion from derived to base. Also, the lack of
operator[] would make such usage unnatural (perhaps Glen uses a
patched shared_ptr?)

The only way I'd want a shared_ptr returned is if shared_ptr were
partially specialized like unique_ptr -- i.e., I could write
shared_ptr<int []>. (Not to go OT, but would a (presumably large)
patch with this change be considered?)


Boost list run by bdawes at, gregod at, cpdaniel at, john at