|
Boost : |
From: timfisken_at_[hidden]
Date: 2001-09-22 20:08:06
I've just started looking at boost::python, and I am having a litte
difficulty with functions that take shared_ptr's as arguments. I'm
not sure if this is due to me misunderstanding how boost::python is
supposed to work, or a bug somewhere in my code, or g++ or something
else entirely.
I created a class 'hello' based on the one in the getting_started2
example, along with a free function 'invite' (again, as in the
example). This worked fine. I then changed invite(const hello&) to
invite(boost::shared_ptr<hello>). Now, when I try and call 'invite'
from python, passing it a 'hello' instance created in python, I
receive an error telling me that the extension class 'hello' does not
wrap '<5hello>' (5hello, I discoverd, is what typeid(hello()).name()
returns, for what that's worth).
I looked for references to any similar problems in the documentation
and in the archive for this list, but I didn't see anything about
this specific issue.
Have I misunderstood how boost::python interacts with smart pointers?
invite(hello*) works the same as invite(hello&). Further, if I return
a shared_ptr<hello> to python from a C++ function, this works just
like a 'hello' instance in python, except that it _does_ work with
shared_ptr version of 'invite'. This leads me to think that, from the
python side, it is supposed to be transparent whether the C++
function takes a T&, a T* or a shared_ptr<T>. Is this not the case?
For what it's worth, I'm using boost 1.24.0, python 1.52 and g++
2.95.3; I don't know if one of these might be causing my
difficulties, although I suspect the problem is of my own making.
Thanks,
-- Tim Fisken 223 King's College 07740 928082
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk