[C++-sig] Calling func that takes intrusive_ptr with intrusive_ptr... (original) (raw)
Alex Mohr amohr at pixar.com
Tue Dec 20 01:15:29 CET 2005
- Previous message: [C++-sig] Cycles won't be deleted
- Next message: [C++-sig] Custom smart pointer progress (I think?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hmm.. I was expecting this to work. Any ideas as to why it doesn't?
Thanks,
Alex
#include <boost/python.hpp> #include <boost/smart_ptr.hpp> #include
using namespace boost::python; using boost::intrusive_ptr; using std::string;
class Base { public: virtual ~Base() {} }; class Derived : public Base { public: virtual ~Derived() {} };
void intrusive_ptr_add_ref(Base *base) {} void intrusive_ptr_add_ref(Base *base) {}
intrusive_ptr makeDerived() { return intrusive_ptr(new Derived()); }
string takesBasePtr(intrusive_ptr const &base) { return "takesBasePtr"; }
BOOST_PYTHON_MODULE(foo) { class_<Base, intrusive_ptr >("Base", no_init); class_<Derived, intrusive_ptr, bases > ("Derived", no_init) .def("init", make_constructor(makeDerived)) .def("takesBasePtr", takesBasePtr) ; }
==================================================
from foo import * d = Derived() d.takesBasePtr() Traceback (most recent call last): File "", line 1, in ? Boost.Python.ArgumentError: Python argument types in Derived.takesBasePtr(Derived) did not match C++ signature: takesBasePtr(boost::intrusive_ptr)
- Previous message: [C++-sig] Cycles won't be deleted
- Next message: [C++-sig] Custom smart pointer progress (I think?)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]