Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] scoped_array / shared_array (size_t) constructor
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-11-04 20:17:18


On Fri, Nov 4, 2011 at 6:02 PM, Rhys Ulerich <rhys.ulerich_at_[hidden]> wrote:
>>>> 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
>>
>> Why not?
>
> I'll chime in.  None of boost::{shared,scoped}_{ptr,array}<T> allocate
> T instances within their constructors.  That's (part of) what
> make_shared is intended to do.

Why was it done that way (for shared_ptr) and does that rationale also
apply to scoped/shared_array?

> Avoiding redundant type specifications
> is auto/BOOST_AUTO's job.  Rather than adding potentially ambiguous
> constructor overloads to well-defined, heavily-used classes, spend the

Do you mean the () vs (0) issue? Why's that such a big problem?

> time implementing boost::make_{shared,scoped}_array instead.  auto +
> make_{shared,scoped}_array will accomplish what you want (avoiding
> specifying the type twice) and the functionality will benefit a much
> broader audience.

I'm confused. Why would it benefit a broader audience?

auto and move constructors aren't available in C++03 and auto doesn't
work for member vars.

-- 
Olaf

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk