
On Sat, Dec 08, 2012 at 06:24:08PM +0100, Philipp Kraus wrote:
On 2012-12-08 17:45:07 +0100, Andrew Holden said:
I would ini tialize the shared pointer like so:
boost::shared_ptr <MyType> ptr;
MyType *temp_ptr = cptr_open(); //Use a temporary pointer to avoid initializing the shared pointer with null.
if (temp_ptr) ptr.reset(temp_ptr, &cptr_close); //Now discard temp_ptr
O http://www.boost.org/doc/libs/1_52_0/libs/smart_ptr/shared_ptr.htm#construct... I found that I can use a ctor with template
shared_ptr(Y * p, D d); and D is a dtor call. Do you have an example for D ?
'D' can be any type whose value 'd' is callable as d(p). This includes,
but is not limited to:
D: std::function