Subject: Re: [boost] [Smart Ptr][Bind] Implementaion of Weak Callback Function
From: Artyom (artyomtnk_at_[hidden])
Date: 2009-03-22 01:41:11
> foo = bind( &bar::slot, bind(
> &weak_ptr<bar>::lock, weak_ptr<bar>(
> bar_ptr ) ) );
Such solution may work if you would write
if(!this) throw something();
But I this is just a hack.
More then that, throwing is not good idea because generally
I do not want this situation be treated as a error.
> However, one of those binds must be persisting the smart
> somewhere, because calling foo always has an effect for me,
> where I
> would expect it to segfault after the shared_ptr is reset,
> lock() would return a null shared_ptr. You might be able to
> see the
> problem though, and get where you want to be.
Such "second" bind should return a "void" function that does
nothing, that what I solve in weak_fn.
Actually the code of weak_fn is quite simple (when using variadic
templates, otherwise it is just many copies of same code for 0, 1
and N parameters).
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk