Boost logo

Boost Users :

Subject: Re: [Boost-users] Use boost::shared_ptr with boost::adaptors
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2012-05-01 04:49:59


On Tue, May 1, 2012 at 1:09 AM, Robert Jones <robertgbjones_at_[hidden]>wrote:

> On Mon, Apr 30, 2012 at 11:13 PM, Jeffrey Lee Hellrung, Jr. <
> jeffrey.hellrung_at_[hidden]> wrote:
>
>> On Mon, Apr 30, 2012 at 3:05 AM, Robert Jones <robertgbjones_at_[hidden]>wrote:
>>
>>> When you put it that way I can see your point, but just from the code
>>> the OP presented the intermediate shared_ptr's should persist until
>>> the end of the expression.
>>>
>>
>> I'm not sure what you mean here; do you mean there's a bug on the boost
>> side of the things in the original code listing?
>>
>
> Hmmm...., a bug... no... that might be overstating it I think. From your
> imagined function it's just an intrinsic limitation of a
> pragmatic implementation.
>

Okay, just checking!

But what I meant was that the OP's problematic statement was
>
> boost::for_each(vec
> | transformed(bind(&trasform, _1))
> | indirected,
> bind(&foo::bar, _1));
>
> which is a single expression, so it's reasonable to anticipate that
> 'temporary' shared_ptrs created in the course of evaluating
> this expression should persist until the end of the expression. Ok, I know
> there's lots of holes in that if you analyse it carefully,
> not least that the shared_ptrs in question are not ever explicit, so the
> rules aren't required to apply, but it might be reasonable to
> expect that they would persist.
>
> I'm really not nailing my colours to the mast here, just speculating, so
> be gentle!
>

I thought this was what you meant, and I sympathize :) It is nontrivial and
opaque why that construct will not work, and I'd even agree that it's
reasonable to expect it to work. This does leave me with a somewhat
unsatisfactory feeling, but...I don't immediately see a satisfactory fix
(other than "don't do that") :/

- Jeff



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net