On May 22, 2012 8:38 AM, "Yoann Chaumy" <spartan...@hotmail.com> wrote: > > > Hi, > I will use a shared pointer to my Python script > > I expose my class : > > class_<handler::Target, boost::shared_ptr<handler::Target> >("Target") > .def("getRadius", &handler::Target::getRadius) > .def("setRadius", &handler::Target::setRadius) > .def("setPosition", &handler::Target::setPosition) > ; > > > and I use a method "getTestTarget" who return a shared pointer on my member variable > > vgd::Shp<vgSofa::handler::Target> InterfaceScriptBoost::getTestTarget() > { > return UlisBoost::m_testTarget; > } > > > > And the exposition of is methode is : > > def("getTestTarget", &dtUlis::InterfaceScriptBoost::getTestTarget, python::return_value_policy<python::reference_existing_object>()); > > > > I want to know if it is true ? > > Any help would be appreciated, thank you >
If you are returning a smart pointer, there is no need to use a call policy like return_value_policy<...>. However, you have wrapped the class with boost::shared_ptr and are returning a different kind of shared pointer. That won't work. It's easier if you can just use boost::shared_ptr everywhere, but it is also possible to set up conversions for a custom smart pointer. HTH Jim
_______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig