我用std::mapC++ 实现了一个类,并使用SWIG创建了接口,以便从Java调用.但是没有迭代器对象允许我遍历SWIG包中的条目std::map.有谁知道如何创建迭代器?
我正在使用SWIG为C++库编写PHP包装器,但是我在使用具有模板类型实例的结构作为数据成员时遇到了问题.
假设我有以下头文件:
template <typename>
struct myvector
{
};
struct S
{
myvector<int> v;
};
myvector<int> foo();
S bar();
Run Code Online (Sandbox Code Playgroud)
和接口文件:
%module test
%{
#include "test.hpp"
%}
%include "test.hpp"
%template(IntVec) myvector<int>;
Run Code Online (Sandbox Code Playgroud)
当我尝试使用直接返回的函数时myvector,它工作正常:
$v1 = test::foo();
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用返回S对象的函数,并尝试访问其类型为的数据成员时myvector:
$s = test::bar();
$v2 = $s->v;
Run Code Online (Sandbox Code Playgroud)
我在运行时收到以下错误:
PHP Fatal error: Class 'myvectorT_int_t' not found in test.php on line 145
Run Code Online (Sandbox Code Playgroud)
我可能错过了我的界面文件,但我不知道是什么.有人可以帮忙吗?