简体   繁体   中英

How to wrap final tempate class from C++ using swig?

I am trying to wrap a template which is marked as final from C++ to C# without success. Swig will say "Template 'Test' undefined"

It works if I remove the final keyword but the header isn't under my control.

%module SwigTest
template <typename T>
class Test final
{
    public:
    T a;
};
%template(TestBool)  Test <bool>;

Does the final effect the name in any way? I tried

%template(TestBool)  Test final <bool>;

and similar combinations but no success.

Looks like SWIG doesn't understand final yet. You can trivially work around this with the pre-processor in SWIG though:

%module SwigTest

#define final

template <typename T>
class Test final
{
    public:
    T a;
};
%template(TestBool)  Test <bool>;

This will work with no negative impact.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM