|
Boost Users : |
Subject: Re: [Boost-users] Nesting bind with shared_ptr<T>::operator* and ref
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2013-06-04 15:35:57
AMDG
On 06/04/2013 10:36 AM, Chris Stankevitz wrote:
> On Mon, Jun 3, 2013 at 5:33 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
>> using boost::phoenix::bind;
>> using boost::phoenix::placeholders::_1;
>> bind(x, *bind(GetC, _1))
>
> Steven,
>
> Thank you, I did not know about phoenix's operator capability.
>
> Do you agree with this statement:
>
> GetC increments the shared_ptr's reference count when it returns a
> shared_ptr to operator*. After operator* dereferences, it decrements
> the shared_ptr reference count. Then the function "x" is executed.
> Hence nobody is holding a reference count on behalf of function "x".
>
I think that's correct. Boost.Phoenix doesn't
try to mimic built-in temporary lifetime rules.
I suppose you could get around it like this:
let(_a = bind(GetC, _1)) [ bind(x, _a) ]
In Christ,
Steven Watanabe
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