Hi again :D, To solve my old problem, I'm trying create custom constructor which return a shared_ptr<MyClass> like that code:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class my_class_wrapper : my_class, python::wrapper<my_class> { ...... } shared_ptr<my_class_wrapper> _create_object(parent *p) { return shared_ptr<my_class_wrapper>(new my_class_wrapper(p), _my_delete_function); } shared_ptr<my_class_wrapper> _create_object2() { return shared_ptr<my_class_wrapper>(new my_class_wrapper(0), _my_delete_function); } class_<my_class_wrapper>("MyClass", python::no_init) .def("__init__", python::make_constructor(_create_object)) .def("__init__", python::make_constructor(_create_object2)) .def("get_parent", &MyClass:getParent, return_value_policy<reference_existing_object>()); -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- but during my python test, the function get_parent not return the same python object created in the object constructor. my test is: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- parent = MyClass() child = MyClass(parent) if (child.get_parent() != parent) print "FAIL" else print "OK" -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Always I got the "FAIL" message, but if I remove the custom constructor the test pass. What I doing wrong all my classes inherit from "python::wrapper<X>". Then I think all classes have implicit conversion to "shared_ptr" correct? BR -- Renato Araujo Oliveira Filho _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig