M
momobear
while as I try to wrap a function using boost-python, I find a strange
situation.
#include <iostream>
#include <string>
#include <vector>
#include <boost/python/list.hpp>
#include <boost/python.hpp>
using namespace boost:ython;
int printlist(list &l){
std::vector<std::string> a;
a.push_back("c++");
a.push_back("javascript");
for (std::vector<std::string>::iterator p = a.begin(); p != a.end(); +
+p)
l.append(*p);
return 0;
}
BOOST_PYTHON_MODULE(wlist){
def("printlist", printlist);
}
in the up code,"int printlist(list &l)" at first time I missed add &
left of l. but when I run the following python code,
#!/usr/local/bin/python
a = list()
a.append('linux')
import wlist
wlist.printlist(a)
print a
they get the same result.
linux
c++
javascript
anyone help me figure out what's wrong here. thanks.
situation.
#include <iostream>
#include <string>
#include <vector>
#include <boost/python/list.hpp>
#include <boost/python.hpp>
using namespace boost:ython;
int printlist(list &l){
std::vector<std::string> a;
a.push_back("c++");
a.push_back("javascript");
for (std::vector<std::string>::iterator p = a.begin(); p != a.end(); +
+p)
l.append(*p);
return 0;
}
BOOST_PYTHON_MODULE(wlist){
def("printlist", printlist);
}
in the up code,"int printlist(list &l)" at first time I missed add &
left of l. but when I run the following python code,
#!/usr/local/bin/python
a = list()
a.append('linux')
import wlist
wlist.printlist(a)
print a
they get the same result.
linux
c++
javascript
anyone help me figure out what's wrong here. thanks.