I get a very similar issue as in: unexpected result iterating over a boost::python vector_indexing_suite
I have the following C++ code:
#include <vector>
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using namespace boost::python;
class Composite {
public:
std::string name;
std::vector<Composite*>& getChildren() {
return children;
};
std::vector<Composite*> children;
};
typedef std::vector<Composite*> CompositeArray;
BOOST_PYTHON_MODULE(coin)
{
class_<CompositeArray>("CompositeArray")
.def(vector_indexing_suite<CompositeArray, true>());
class_<Composite>("Composite", "Composite*", init<>())
.def("getChildren", &Composite::getChildren, return_internal_reference<>())
.def_readwrite("name", &Composite::name, "str")
;
}
And the following Python code:
import coin
gna = coin.Composite()
gna.name = "test"
gna2 = coin.Composite()
gna2.name = "test2"
gna.getChildren().append(gna2)
for slip in gna.getChildren():
print(slip.name)
produces the error:
Traceback (most recent call last):
File "gna.py", line 34, in <module>
for prout in gna.getChildren():
TypeError: No to_python (by-value) converter found for C++ type: class Composite * __ptr64
This was working fine with Boost 1.59, but not anymore with Boost 1.60.
Any idea ?
Edit: I tried by updating (see proposal below) :
class_<Composite>("Composite", "Composite*", init<>())
to:
class_<Composite, Composite*>("Composite", "Composite*", init<>())
And I confirm that it is working with boost 1.59 but not boost 1.60.