[C++-sig] wrapping reference to c++ object

harold fellermann harold at imb-jena.de
Thu Mar 13 16:15:40 CET 2003


hi.

As you might know in the meanwhile, I want to insert references (not 
instances)
of C++ objects into a boost::python::list. I thought that calling

CPPObject cpp_obj;
list.insert(0,handle<>(borrowed(cpp_obj)))

would do the thing. According to the documentation I need to inherit 
from
PyObject:

class CPPObject : public PyObject
{
	// [...]
};

and as soon as I do this, my code is compiled without error, but failed 
in
the constructor of CPPObject. As stated in the Python/C-API, "you never 
declare
an automatic or static variable of type PyObject, only pointer 
variables of
type PyObject* can be declared." So how can the references be stored?


- harold -


--
"I know what I believe. I will continue to articulate what I believe
  and what I believe - I believe what I believe is right."
-- George W. Bushman





More information about the Cplusplus-sig mailing list