我面临着与std :: vectors,C++ SWIG Python的Wrap std :: vector类似的问题- 但它不仅仅是简单的C++解析.我的C++代码中有以下内容
namespace ns {
typedef unsigned long long uint64_t;
typedef std::vector<uint64_t> Vector;
typedef std::vector<Vector> VectorOfVectors;
class MyClass {
/// ...
/// Returns a reference to the internal vector allocated in C++ land
const VectorOfVectors &GetVectors() const;
};
}
Run Code Online (Sandbox Code Playgroud)
并在SWIG包装器中
%module myswig
// ...
%template(Uint64V) std::vector<ns::uint64_t>;
%template(VUint64V) std::vector<std::vector<ns::uint64_t> >;
Run Code Online (Sandbox Code Playgroud)
所以包装工作正常,包括类,我可以检索类的向量向量确定:
import myswig
m = myswig.MyClass()
v = m.GetVectors()
print v
Run Code Online (Sandbox Code Playgroud)
这给了我:
<myswig.VUint64V; proxy of <Swig Object of type 'std::vector< std::vector< ns::uint64_t,std::allocator< …Run Code Online (Sandbox Code Playgroud)