Wrapping C++ template method with keyword name using SWIG

I'm wrapping some C++ code using SWIG to generate Python code. The C++ class has a template method as defined as such:

class Array {
public:
    template <typename T> std::vector<T> as<T>();
...
}

In my SWIG interface file I have wrapped this function as such:

%template(fdata) Array::as<float>();
%template(idata) Array::as<int>();
...

This works fine in SWIG 3.0.0 but when I try to compile this in a newer version such as 3.0.12 I get a bunch of the following warnings:

Warning 314: 'as' is a python keyword, renaming to '_as'
Warning 503: Can't wrap '_as< float >' unless renamed to a valid identifier.

and the fdata , idata , etc. methods are not generated.

I'm not sure what is wrong as this as method is restricted to the C++ code, I never generate an as method on the Python side.

Any help is appreciated.

链接地址: http://www.djcxy.com/p/48342.html

上一篇: 用户未登录时重定向到登录页面

下一篇: 使用SWIG包装关键字名称的C ++模板方法