PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/template_forward.i

#
Swig | 71 lines | 55 code | 16 blank | 0 comment | 0 complexity | b30d3032c302fd6126009ed50b9b7247 MD5 | raw file
 1%module template_forward
 2
 3%{
 4namespace foo {
 5template<class T> class bar { };
 6}
 7%}
 8
 9namespace foo {
10   template<class T> class bar;
11};
12
13%inline %{
14namespace foo {
15   double test1(const bar<double> &x) { return 0; }
16   bar<double> test2() {
17	return bar<double>();
18   }
19}
20%}
21
22
23
24%inline {
25  // Forward declarations
26  template<class RangeScalar, class DomainScalar = RangeScalar> class LinearOpBase;
27  template<class Scalar>  class VectorBase;  
28}
29
30
31%inline {
32  // Class Describable
33  class Describable {
34  public:
35    void describe() {}
36  };
37  
38  // Class LinearOpBase
39  template<class RangeScalar, class DomainScalar> 
40    class LinearOpBase : virtual public Describable {
41    public:
42      
43    }; // end class LinearOpBase<RangeScalar,DomainScalar>
44  
45  // Class VectorBase
46  template<class Scalar>
47    class VectorBase : virtual public LinearOpBase<Scalar>
48    {
49    public:
50      using LinearOpBase<Scalar>::describe;
51    }; // end class VectorBase<Scalar>
52  
53}
54
55
56%template (LinearOpBase_double)    LinearOpBase<double>;
57%template (VectorBase_double)      VectorBase<double>;
58%template (LinearOpBase_int)    LinearOpBase<int,int>;
59%template (VectorBase_int)      VectorBase<int>;
60
61// Template forward class declarations mixing class and typename without always naming the templated parameter name
62%inline %{
63template <class> class TClass1;
64template <typename> class TClass2;
65template <class, typename> class TClass3;
66template <class, class, class> class TClass4;
67template <typename, typename> class TClass5;
68template <typename, class K = double> class TClass6;
69template<typename, class K, class C = K> class TClass7;
70%}
71