c++ - 包装 std::vector 的 std::vector,C++ SWIG Python

标签 c++ python vector swig

我想使用 SWIG 将 vector 的 C++ vector 包装为 Python 代码。

是否可以包装这种类型的 vector ?

std::vector<std::vector<MyClass*>>;

在接口(interface)文件MyApplication.i中,我添加了这些行:

%include "std_vector.i"
%{ 
#include <vector> 
%} 

namespace std {
   %template(VectorOfStructVector) vector<vector<MyClass*>>;
}

但是,执行 SWIG 时出现错误。我能够包装这种类型(使用对 vector 的引用):

 std::vector<std::vector<MyClass*>*>;

但是,它无法正常工作,我无法访问这些项目。这就是为什么我对这种类型感兴趣(没有引用):

 std::vector<std::vector<MyClass*>>;

有什么想法吗?

最佳答案

这是一个C++解析问题吗?

 std::vector<std::vector<MyClass*> >;
 ---Important space---------------^

关于c++ - 包装 std::vector 的 std::vector,C++ SWIG Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3761861/

相关文章:

python - 将 C/C++ 代码 "typedef struct"迁移到 python

通过过滤隐藏对象来减小绘图的 PDF 文件大小

c++ - 为什么在 Directshow 中捕获图形不起作用?

c++ - MFC 应用程序中的灯箱样式对话框

python - 如何调试gunicorn应用程序?

Javascript:如何移动与其旋转相关的上下文对象

c++ - 使用指向内部缓冲区的指针 move 语义

c++ Derived Default复制构造函数用什么初始化Base复制构造函数?

c++ - Floyd-Warshall 算法的路径重建不适用于某些值

python - 如何从两个字典的列表中收集具有相同键的值