Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] scoped_array / shared_array (size_t) constructor
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2011-11-04 12:02:50

On Friday, November 04, 2011 16:51:12 Olaf van der Spek wrote:
> On Tue, Nov 1, 2011 at 5:40 PM, Richard Hadsell
> <hadsell_at_[hidden]> wrote:
> > On 11/01/2011 12:20 PM, Olaf van der Spek wrote:
> >> Adding a (size_t) constructor would produce ambiguity errors, but
> >> those are easy to fix by using the default constructor instead. Would
> >> that be acceptable?
> >
> > That sounds like a good idea.
> Great. Does anyone else have comments / concerns about a (size_t)
> constructor?

I still don't like the idea. If you really want to add this feature, please
retain the current interface intact. You could add a special manipulator to
make the allpcation request explicit, like this:

  boost::scoped_array< int > p(boost::allocate_count(10));

Here allocate_count is a simple class that holds the size of the array to be
allocated. Alternatively, Boost.Parameter could be used, but it is quite heavy
for such basic tools like smart pointers.

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