
Hello Scott,
Thanks.
It seems to be one of the simplest way to get to my needs
to declare another companion auto_free_helper.
It's better than none, if not the best.
I'm using this technique for stream:
std::ofstream outstream(strPath);
boost::shared_ptrstd::ofstream os_auto_closer(&outstream,
boost::bind(&std::ofstream::close, _1));
B/Rgds
Max
----- Original Message -----
From: Scott McMurray
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 _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users ------------------------------------------------------------------- 新浪空间——与朋友开心分享网络新生活!(http://space.sina.com.cn/ )