consider the following class declarations:
namespace X {
template
class Foo {
public:
Foo();
virtual ~Foo();
T value() const;
};
You can achieve the result you want by doing:
%include "stl.i"
%include "std_string.i"
%include "std_vector.i"
namespace X {
using namespace std;
%rename(FooVectorInt) Foo >;
class Foo > {
public:
virtual ~Foo();
int value( const int ) const;
};
template
class Foo {
public:
Foo();
virtual ~Foo();
T value() const;
};
%template(FooInt) Foo;
%template(FooString) Foo;
}
This works because what you write in the interface file isn't C++ and all that matters is that the correct code is generated by SWIG. If you want to repeat this lots you can write macros (which is close to what %template is anyway).
Still this isn't a very clean solution - I expected this to "just work" with the specialisations and I can't see a simpler workaround either.