Skip to content

Instantly share code, notes, and snippets.

@octavifs
Last active June 7, 2017 12:32
Show Gist options
  • Save octavifs/5362272 to your computer and use it in GitHub Desktop.
Save octavifs/5362272 to your computer and use it in GitHub Desktop.
Converts C++ std::vector to boost::python::list
// Converts a C++ vector to a python list
template <class T>
boost::python::list toPythonList(std::vector<T> vector) {
typename std::vector<T>::iterator iter;
boost::python::list list;
for (iter = vector.begin(); iter != vector.end(); ++iter) {
list.append(*iter);
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment