尝试公开具有以下类型的映射向量(键为字符串,值为结构对象):
// boost includes ..
struct MyStruct {
double a;
vector<double> vec;
bool operator==(const MyStruct& other) {return false;}
bool operator!=(const MyStruct& other) {return true;}
};
typedef map<string, MyStruct> MyMap;
typedef vector<MyStruct> MyVec;
typedef vector<MyMap> MyVec2;
BOOST_PYTHON_MODULE(_axstatistics)
{
py::class_<MyStruct>("MyStruct")
.def_readwrite("a", &MyStruct::a)
.def_readwrite("vec", &MyStruct::vec)
;
py::class_<MyMap>("MyMap")
.def(map_indexing_suite<MyMap>());
py::class_<MyVec>("MyVec")
.def(vector_indexing_suite<MyVec>());
// uncomment and boum
// py::class_<MyVec2>("MyVec2")
// .def(vector_indexing_suite<MyVec2>());
}
这适用于MyVec
,但不适用于MyVec2
,我收到一个几乎无法读取的编译错误
有人对这种模式有想法或经验吗
提前支付Thx
通过在
MyMap
和MyVec2
类上定义==
运算符来运行它相关问题 更多 >
编程相关推荐