Re: how to make a deletion slot?



On Mon, 2006-10-30 at 01:00 +0200, Paul Pogonyshev wrote:
> Hi,
> 
> Is there a way to make a slot that calls `delete arg' on its argument
> pointer (of a known type.)  It is trivial to write a one-line function
> for it, but maybe there is a standard one ready for this?

its not as trivial as you might think, because the lifetime of the
object during event processing can be important. generally, i like to
use a one-shot idler handler, combined with a template function:

template<class T> bool delete_when_idle (T* obj) {
	delete obj;
}

    ... signal_idle().connect (bind
(ptr_fun(delete_when_idle<TypeOfObject>), obj));





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]