[C++-sig] shared_ptr with custom destructor
Renato Araujo
renatox at gmail.com
Mon Nov 24 22:26:09 CET 2008
Hi all,
I would like to specify during the class_ declaration use a shared_ptr
with custom release function.
shared_ptr has a constructor where you can pass a function to call in
the release, I would like to use this in a generic form.
I already tried some like that:
shared_ptr<BaseClass> _custom_constructor()
{
return shared_ptr<BaseClass>(new BaseClass(), _release_func);
}
class_ <BaseClass, shared_ptr<BaseClass> >
("BaseClass").def("__init__", make_constructor(_custom_constructor));
but this not work to class derived from BaseClass: my
_custom_constructor is not called to others class.
I would like something more generic where I can declare in class_
template, something like that:
class_<MyClass, boost::shared_ptr<MyClass, release_func> ("MyObject")
.......
There is something like that? How is the best way to do this?
BR
--
Renato Araujo Oliveira Filho
More information about the Cplusplus-sig
mailing list