[C++-sig] Exposing a class with private dtor
Abhi
abhi at qualcomm.com
Thu May 4 19:32:21 CEST 2006
Question 1. How do I expose a class which has a private dtor? The class has
static method to destroy it instead?
class PrivateCtorDtor
{
public:
int nonStaticVariable;
static int staticVariable;
static PrivateCtorDtor* allocate();
static void free(PrivateCtorDtor* );
static int getStaticVariable()
{
return staticVariable;
}
private:
~PrivateCtorDtor();
private:
PrivateCtorDtor();
};
Question 2: I tried doing this by wrapping the class with a derived class.
For example:
bp::class_<PrivateCtorDtor_YWrapper>("PrivateCtorDtor", bp::no_init)
where PrivateCtorDtor_YWrapper class is derived from the PrivateCtorDtor
class.
And PrivateCtorDtor_YWrapper dtor calls the free static method of the
PrivateCtorDtor class.
But I __could not get it to work__.
Question 3: Is it possible to do this without creating the derived class as
above? For example, by doing a .def on some python function name (either
"__del__" or something like that)
Question 4: Is it even possible using Boost.Python?
thanks
- Abhi
More information about the Cplusplus-sig
mailing list