This is an follow up question to std::vector to boost::python::list
I tried the provided example:
// C++ code
typedef std::vector<std::string> MyList;
class MyClass {
MyList myFuncGet();
void myFuncSet(MyList& list)
{
list.push_back("Hello");
}
};
// My Wrapper code
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(mymodule)
{
class_<MyList>("MyList")
.def(vector_indexing_suite<MyList>() );
class_<myClass>("MyClass")
.def("myFuncGet", &MyClass::myFuncGet)
.def("myFuncSet", &MyClass::myFuncSet)
;
}
But when I try to actually use it in Python I get an error (See bottom).
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mymoduleimport *
>>> mc = MyClass()
>>> p = []
>>> mc.myFuncSet(p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Boost.Python.ArgumentError: Python argument types in
MyClass.myFuncSet(MyClass, list)
did not match C++ signature:
myFuncSet(MyClass {lvalue}, std::vector<std::string, std::allocator<std::string> > {lvalue})
From what I've been able to gather by reading various other sites & posts, a converter is required. Can someone complete my example by adding in the necessary converter code? I'd do it myself, but I'm not familiar enough with boost to know what such a converter looks like.
Thanks in advance!