Luz
Luz

Reputation: 524

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.

Upvotes: 3

Views: 316

Answers (1)

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.

Upvotes: 4

Related Questions