[C++-sig] Exposing a class with private dtor

Roman Yakovenko roman.yakovenko at gmail.com
Sun May 7 15:45:50 CEST 2006


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 libs\python\src\object\class.cpp

      static void instance_dealloc(PyObject* inst)
      {
          instance<>* kill_me = (instance<>*)inst;

          for (instance_holder* p = kill_me->objects, *next; p != 0; p = next)
          {
              next = p->next();
              p->~instance_holder();
              instance_holder::deallocate(inst, dynamic_cast<void*>(p));
          }


>
> thanks
> - Abhi

--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/



More information about the Cplusplus-sig mailing list