I have a templated c++ array class which uses the standard vector class:
#include
#include
using namespace std;
template
You can extend each type separately, like this:
%extend doubleArray1D {
Note that extension is virtual in that it just tells SWIG to generate code for extra functions that will be part of exported class but such function only has access to public interface of your c++ class.
If you have a whole bunch of template instances, you could define and use a SWIG macro:
%define ArrayExtend(name, T)
%extend name {
T& __getitem__(int i) {
return (*self)[i];
}
}
%enddef
ArrayExtend(Array1D, double)
ArrayExtend(Array1D, int)