python - 提升地图的python向量..(结构)..不走运
问题描述
尝试公开具有以下类型的映射向量(键是字符串,值是结构对象):
// 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
,我得到一个几乎不可读的编译错误。
有人对这种模式有想法或有经验吗?
提前谢谢..
解决方案
通过在and类上定义==
运算符来运行它。MyMap
MyVec2
推荐阅读
- amazon-cloudformation - 如何在 CDK 中创建 NAT 网关,然后将路由添加到指向 CIDR 的私有子网?
- java - Java中句子的用户输入
- java - 如何使用 AWS SES 在电子邮件中添加标签?
- c# - 如何使用 CloudFormation 模板连接到现有 EC2 实例并执行 shell 文件
- python - 如何将张量转换为 NumPy 数组
- python - 如何为单个集合动态更改mongodb中的文本索引?
- c# - 提高时间间隔计算的性能
- c - sprintf“访问冲突读取位置”异常
- python - 如何将 Pandas 时间戳转换为 Matplotlib 的 float64 格式?
- javascript - 设置覆盖高度等于父 div,不等于屏幕高度