PageRenderTime 44ms CodeModel.GetById 21ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_template_parameters
  2. %inline %{
  3. namespace pfc {
  4. template<typename t_item, template <typename> class t_alloc> class array_t {};
  5. template<typename t_item> class alloc_fast {
  6. public:
  7. typedef t_item alloc_type;
  8. };
  9. }
  10. template<typename t_item, typename t2> class list_impl_t {};
  11. template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
  12. class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > {
  13. public:
  14. t_item item;
  15. // typename t_alloc<t_item>::alloc_type allotype; // SWIG can't handle this yet
  16. void xx() {
  17. typename t_alloc<t_item>::alloc_type atype; // this type is the same as t_item type
  18. atype = true;
  19. }
  20. };
  21. void TestInstantiations() {
  22. pfc::array_t<int, pfc::alloc_fast> myArrayInt;
  23. list_impl_t<int, pfc::array_t<int, pfc::alloc_fast> > myListImplInt;
  24. (void) myArrayInt;
  25. (void) myListImplInt;
  26. }
  27. %}
  28. %template(ListImplFastBool) list_impl_t<bool, pfc::array_t<bool, pfc::alloc_fast> >;
  29. %template(ListFastBool) list_t<bool, pfc::alloc_fast>;
  30. %template(ListImplFastDouble) list_impl_t<double, pfc::array_t<double, pfc::alloc_fast> >;
  31. %template(ListDefaultDouble) list_t<double>;