diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 20e08f8c8..7efe2578e 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -171,6 +171,7 @@ CPP_TEST_CASES += \ template_enum \ template_enum_ns_inherit \ template_enum_typedef \ + template_explicit \ template_forward \ template_inherit \ template_inherit_abstract \ diff --git a/Examples/test-suite/template_explicit.i b/Examples/test-suite/template_explicit.i new file mode 100644 index 000000000..0ef7cea53 --- /dev/null +++ b/Examples/test-suite/template_explicit.i @@ -0,0 +1,51 @@ +/* File : example.i */ +%module "template_explicit" + +%warnfilter(801) vector; /* Ruby, wrong class name */ +%warnfilter(801) vector; /* Ruby, wrong class name */ +%warnfilter(801) vector; /* Ruby, wrong class name */ +#pragma SWIG nowarn=320 + +/* Let's just grab the original header file here */ + +%inline %{ + +template T max(const T a, const T b) { return a>b ? a : b; } + +template class vector { + T *v; + int sz; + public: + vector(int _sz) { + v = new T[_sz]; + sz = _sz; + } + T &get(int index) { + return v[index]; + } + void set(int index, T &val) { + v[index] = val; + } + // This really doesn't do anything except test const handling + void testconst(const T x) { } +}; + +/* Explicit instantiation. SWIG should ignore */ +template class vector; +template class vector; +template class vector; +%} + +/* Now instantiate some specific template declarations */ + +%template(maxint) max; +%template(maxdouble) max; +%template(vecint) vector; +%template(vecdouble) vector; + +/* Now try to break constness */ + +%template(maxintp) max; +%template(vecintp) vector; + +