[C++-sig] Exposing a class with private dtor
abhi at qualcomm.com
Mon May 8 23:03:40 CEST 2006
Not sure on how to use this in my code/wrappers?
The only way I can think of exposing a class with a private dtor to python
is via composition. For example,
static destroy(A* );
a = new A();
And then expose A_wrap as "A" to python.
Not very scalable!
--On Sunday, May 07, 2006 4:45 PM +0300 Roman Yakovenko
<roman.yakovenko at gmail.com> wrote:
> On 5/4/06, Abhi <abhi at qualcomm.com> wrote:
>> Question 1. How do I expose a class which has a private dtor? The class
>> has static method to destroy it instead?
>> Question 4: Is it even possible using Boost.Python?
> I think you can do it. I would like to be wrong, but..
> Here is, I think, relevant piece of code from
> static void instance_dealloc(PyObject* inst)
> instance<>* kill_me = (instance<>*)inst;
> for (instance_holder* p = kill_me->objects, *next; p != 0; p =
> next = p->next();
> instance_holder::deallocate(inst, dynamic_cast<void*>(p));
>> - Abhi
> Roman Yakovenko
> C++ Python language binding
More information about the Cplusplus-sig