如何在python包装器中定义C ++类的数据成员

时间:2019-04-25 04:53:03

标签: pybind11

我正在尝试为cpp文件编写python包装器。 cpp文件由一个类组成,该类包含用户定义的数据成员,构造函数和成员函数。如何在包装文件中定义cpp文件的数据成员?

ex.cpp

c1类

{

公开

    using ct_coeff_type = std::uint64_t;

    using size_type = IntArray<ct_coeff_type>::size_type;

}

我将包装器写为

wrapper.cpp

py :: class_(m,“密文”)

.def(py::init<>())

.def(py::init<const Ciphertext &>())

.def(py::init<MemoryPoolHandle &>())

.def(py::init<std::shared_ptr<SEALContext> &, MemoryPoolHandle &>())

.def(py::init<std::shared_ptr<SEALContext> &, parms_id_type &, MemoryPoolHandle &>())

.def(py::init<std::shared_ptr<SEALContext> &, parms_id_type &, size_type &, MemoryPoolHandle &>())

.def("reserve", (void (Ciphertext::*)(std::shared_ptr<SEALContext> &, parms_id_type &, size_type &)) &Ciphertext::reserve,
    "Allocates enough memory to accommodate the backing array of a ciphertext with given capacity");

0 个答案:

没有答案