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 
8 template<class T> class Foo {
9 public:
~Foo()10   virtual ~Foo() { }
blah()11   virtual char *blah() {
12        return (char *) "Foo";
13   }
foomethod()14   virtual char *foomethod() {
15        return (char *) "foomethod";
16   }
17 };
18 
19 template<class T> class Bar : public Foo<T> {
20 public:
blah()21    virtual char *blah() {
22         return (char *) "Bar";
23    }
24 };
25 
invoke_blah(Foo<T> * x)26 template<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 
42