PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Swig | 39 lines | 31 code | 8 blank | 0 comment | 0 complexity | b908db336410aa707e27020851ab9300 MD5 | raw file
 1%module template_template_parameters
 2
 3
 4%inline %{
 5  namespace pfc {
 6    template<typename t_item, template <typename> class t_alloc> class array_t {};
 7    template<typename t_item> class alloc_fast {
 8      public:
 9        typedef t_item alloc_type;
10    };
11  }
12
13  template<typename t_item, typename t2> class list_impl_t {};
14
15  template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
16    class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > { 
17  public:
18    t_item item;
19//    typename t_alloc<t_item>::alloc_type allotype; // SWIG can't handle this yet
20    void xx() {
21      typename t_alloc<t_item>::alloc_type atype; // this type is the same as t_item type
22      atype = true;
23    }
24  };
25
26void TestInstantiations() {
27  pfc::array_t<int, pfc::alloc_fast> myArrayInt;
28  list_impl_t<int, pfc::array_t<int, pfc::alloc_fast> > myListImplInt;
29  (void) myArrayInt;
30  (void) myListImplInt;
31}
32%}
33
34%template(ListImplFastBool) list_impl_t<bool, pfc::array_t<bool, pfc::alloc_fast> >;
35%template(ListFastBool) list_t<bool, pfc::alloc_fast>;
36
37%template(ListImplFastDouble) list_impl_t<double, pfc::array_t<double, pfc::alloc_fast> >;
38%template(ListDefaultDouble) list_t<double>;
39