Boost logo

Boost :

Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Julien Nitard (julien.nitard_at_[hidden])
Date: 2012-02-15 03:57:58


On Wed, Feb 15, 2012 at 5:40 PM, Olaf van der Spek <ml_at_[hidden]> wrote:
> On Wed, Feb 15, 2012 at 3:30 AM, Julien Nitard <julien.nitard_at_[hidden]> wrote:
>>> An std container of references does not compile, a std container of pointers does.  In code with dynamic polymorphic type systems pointers get used a lot, and often more than they should.
>>
>> An std container of (boost/std)::(shared_ptr/unique_ptr) does compile
>> and should be prefered to raw pointers.
>
> Why?
> If the pointers are non-owning, shared/unique is wrong.

I may just say that you could add weak_ptr to the list to make it look
better, but I guess you're right. I just thought (wrongly) that the
pointers were owning. Sorry.

In the context of the question, though, I was trying to support the
fact that raw pointers are "used a lot, and often more than they
should". I forgot that we're talking on boost and that your usual
metrics and practices won't always hold.

Julien


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