gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 01:58:41 24 4
gpt4 key购买 nike

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

是否可以将这种 vector 的 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com