boost::python: Python list to std::vector

后端 未结 4 2099
庸人自扰
庸人自扰 2020-12-24 01:47

Finally I\'m able to use std::vector in python using the [] operator. The trick is to simple provide a container in the boost C++ wrapper which handles the internal vector s

4条回答
  •  悲哀的现实
    2020-12-24 02:28

    To make your C++ method accept Python lists you should use boost::python::list

    void massadd(boost::python::list& ns)
    {
        for (int i = 0; i < len(ns); ++i)
        {
            add(boost::python::extract(ns[i]));
        }
    }
    

提交回复
热议问题