29 Dec
2008
29 Dec
'08
3:35 a.m.
On Sun, Dec 28, 2008 at 22:29, Max
I have the following code scenario:
A *pa = NULL;
// pa will be allocated here (by 3rd-party function) // by setA(), // whose behavior could not be changed setA(pa); // prototype: void setA(A*& pa)
//...
pa->close();
I think the following is fine: A *pa_ = 0; setA(pa_); boost::shared_ptr<A> pa(pa_, boost::bind(&A::close, _1)); Since the shared_ptr constructor will call the deleter if its internal allocation fails. ~ Scott