/tags/rel-1-3-29/SWIG/Examples/test-suite/template_inherit.i
Swig | 41 lines | 31 code | 8 blank | 2 comment | 0 complexity | f6f52c19e4cf995b0aded78a64d5d2f2 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1/* File : example.i */ 2%module template_inherit 3 4/* This example tests template inheritance to see if it actually works */ 5 6%inline %{ 7 8template<class T> class Foo { 9public: 10 virtual ~Foo() { } 11 virtual char *blah() { 12 return (char *) "Foo"; 13 } 14 virtual char *foomethod() { 15 return (char *) "foomethod"; 16 } 17}; 18 19template<class T> class Bar : public Foo<T> { 20public: 21 virtual char *blah() { 22 return (char *) "Bar"; 23 } 24}; 25 26template<class T> char *invoke_blah(Foo<T> *x) { 27 return x->blah(); 28} 29%} 30 31%template(FooInt) Foo<int>; 32%template(FooDouble) Foo<double>; 33%template(FooUInt) Foo<unsigned int>; 34%template(BarInt) Bar<int>; 35%template(BarDouble) Bar<double>; 36%template(BarUInt) Bar<unsigned>; 37%template(invoke_blah_int) invoke_blah<int>; 38%template(invoke_blah_double) invoke_blah<double>; 39%template(invoke_blah_uint) invoke_blah<int unsigned>; 40 41