Nesting bind with shared_ptr<T>::operator* and ref
Hello,
Can you please help me uncomment out the last "bind" of the program
pasted below? The problem is that it will require some kind of
mechanism to dereference the shared_ptr.
Thank you,
Chris
===
#include
AMDG On 06/03/2013 01:15 PM, Chris Stankevitz wrote:
Hello,
Can you please help me uncomment out the last "bind" of the program pasted below? The problem is that it will require some kind of mechanism to dereference the shared_ptr.
Use Boost.Phoenix which has support for operators. using boost::phoenix::bind; using boost::phoenix::placeholders::_1; bind(x, *bind(GetC, _1)) In Christ, Steven Watanabe
On Mon, Jun 3, 2013 at 5:33 PM, Steven Watanabe
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". Thank you again, Chris
AMDG On 06/04/2013 10:36 AM, Chris Stankevitz wrote:
On Mon, Jun 3, 2013 at 5:33 PM, Steven Watanabe
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
participants (2)
-
Chris Stankevitz
-
Steven Watanabe