Wrap std :: vector的std :: vectors,C ++ SWIG Python [英] Wrap std::vector of std::vectors, C++ SWIG Python
本文介绍了Wrap std :: vector的std :: vectors,C ++ SWIG Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用SWIG将向量的C ++向量包装到Python代码中。
I want to wrap a C++ vector of vectors to Python code by using SWIG.
是否可以包装这种向量的向量?
Is it possible to wrap this type of vector of vectors?
std::vector<std::vector<MyClass*>>;
在接口文件 MyApplication.i
I添加了以下行:
In the interface file MyApplication.i
I added these lines:
%include "std_vector.i"
%{
#include <vector>
%}
namespace std {
%template(VectorOfStructVector) vector<vector<MyClass*>>;
}
但是,当SWIG执行时,我可以包装这种类型(使用向量引用):
But, I'm getting an Error when SWIG is executed. I'm able to wrap this type (using reference to the vector):
std::vector<std::vector<MyClass*>*>;
但是,它不能正常工作,我无法访问项目。这就是为什么我对这种类型感兴趣(没有引用):
But, it's not working properly, I cannot access the items. That's why I'm interested in this type (without the reference):
std::vector<std::vector<MyClass*>>;
任何想法?
推荐答案
是否是C ++解析问题?
Is it a C++ parsing issue?
std::vector<std::vector<MyClass*> >;
---Important space---------------^
这篇关于Wrap std :: vector的std :: vectors,C ++ SWIG Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文