如何使用 swig 从 C++ 包装最终模板 class?
How to wrap final tempate class from C++ using swig?
我正在尝试将标记为最终的模板从 C++ 包装到 C#,但没有成功。 Swig 会说 "Template 'Test' undefined"
如果我删除 final 关键字但 header 不受我控制,它会起作用。
%module SwigTest
template <typename T>
class Test final
{
public:
T a;
};
%template(TestBool) Test <bool>;
最终会影响名字吗?我试过了
%template(TestBool) Test final <bool>;
和类似组合但没有成功。
看起来 SWIG 还不理解 final
。不过,您可以使用 SWIG 中的预处理器轻松解决此问题:
%module SwigTest
#define final
template <typename T>
class Test final
{
public:
T a;
};
%template(TestBool) Test <bool>;
这不会产生负面影响。
我正在尝试将标记为最终的模板从 C++ 包装到 C#,但没有成功。 Swig 会说 "Template 'Test' undefined"
如果我删除 final 关键字但 header 不受我控制,它会起作用。
%module SwigTest
template <typename T>
class Test final
{
public:
T a;
};
%template(TestBool) Test <bool>;
最终会影响名字吗?我试过了
%template(TestBool) Test final <bool>;
和类似组合但没有成功。
看起来 SWIG 还不理解 final
。不过,您可以使用 SWIG 中的预处理器轻松解决此问题:
%module SwigTest
#define final
template <typename T>
class Test final
{
public:
T a;
};
%template(TestBool) Test <bool>;
这不会产生负面影响。