Boost logo

Boost :

Subject: Re: [boost] Rationale for shared_ptr/array including both ptr to control and ptr to data in class
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-09-27 06:57:25


On Tue, Sep 27, 2011 at 4:26 AM, Nathan Ridge <zeratul976_at_[hidden]> wrote:
>
>> > From: Olaf van der Spek
>> > Not having size() and others like begin, end, etc, is a serious
>> > drawback IMO.
>>
>> Then why not simply use either shared_ptr<array<T, N>> or
>> shared_ptr<vector<T>>?
>>
>> Best regards,
>> Robert
>
> shared_ptr<array<T, N>> limits you to cases where you know
> the size of the array at compile time
>
> shared_ptr<vector<T>> results in two dynamic allocations: one
> for the vector object itself, and one for its internal array

It'll also initialize the elements (not wanted) and it provides
another interface.

Olaf


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