我使用痛飲,並在頭文件evidence.h
,我有以下幾點:如何從類聲明中正確導出SWIG typedef?
namespace dai {
class Evidence {
public:
typedef std::map<Var, size_t> Observation;
};
}
而且在痛飲接口文件dai.i
,我有以下幾點:
//The types are defined in both swig and the output cxx file...
%include "../include/dai/evidence.h"
%include "../include/dai/var.h"
#include "../include/dai/evidence.h"
//namespace std {
%{
typedef std::map<Var, size_t> Observation;
%}
// %template(Observation) map<Var, size_t>;
//}
typedef std::map<Var, size_t> Observation;
%template(VecObservation) std::vector<dai::Evidence::Observation>;
我相信, Var使得它正確地生成cxx文件和ml文件,所以我不會進入該部分。正是我遇到的問題,即向我聲明的VecObservation模板添加項目。在test.ml文件,我有以下幾點:
let observation = new_Observation C_void in
let observations = new_VecObservation C_void in
let _ = (invoke observations) "push_back" observation in()
而且我得到對應於push_back
行錯誤:(「沒有找到適當的轉換」失敗)