Boost logo

Boost :

Subject: Re: [boost] [Smart Ptr][Bind] Implementaion of Weak Callback Function
From: Artyom (artyomtnk_at_[hidden])
Date: 2009-03-22 06:06:36


>   weak_ptr< A > p; > >   bind(&A::foo, throw_if_invalid(p)); >   bind(&A::foo, ignore_if_invalid(p)); >   bind(&A::foo, call_if_invalid(p, bar)); // bar I think this is little bit problematic, because proxy weak_ptr_caller should know the signature of A::foo to provide correct "R operator()(args...)" Maybe, additional policy for weak_fn would be better void A::foo(int); function<void(int)> bar; bind(weak_fn(&A::foo,p),_1); // default ignore bind(weak_fn(&A::foo,p,throw_on_invalid()),_1); bind(weak_fn(&A::foo,p,bar),_1); // call bar on invalid This would not require changes in bind and also weak_fn would be useful without bind as well. Like function<void(int)> foobar=weak_fn(&A::foo,p); It would be simple to update weak_fn to add policy Artyom


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk