SWIG : Unable to access constructor with double pointer

旧时模样 提交于 2019-12-08 05:21:29

It is simpler to use a vector directly in the constructor and take advantage of SWIG's vector support:

In the .i file:

%include <std_vector.i>
%template(DoubleVector) std::vector<double>;
%include "GradedComplex.h"

In the .h:

GradedComplex(const std::vector<double>& dbls);

In the .cpp:

GradedComplex::GradedComplex(const vector<double>& dbls) : thre_(dbls)
{
}

n_ can go away, since thre_.size() is the same thing.

Call it with:

c=Item.GradedComplex([1.2,3.4,5.6])

SWIG can handle returning vectors as well, so avg can be:

std::vector<double> GradedComplex::avg() { ... }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!