PageRenderTime 35ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Swig | 57 lines | 46 code | 11 blank | 0 comment | 0 complexity | d0f3d17d0300eb656d716cb92e5528c8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %module template_typedef_class_template
  2. %inline %{
  3. namespace Standard {
  4. template <class T, class U > struct Pair {
  5. T first;
  6. U second;
  7. };
  8. }
  9. %}
  10. // previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap
  11. %typemap(out) Standard::Pair<Standard::iterator, Standard::iterator> "_this_will_not_compile_iterator_"
  12. %typemap(out) Standard::Pair<Standard::const_iterator, Standard::const_iterator> "_this_will_not_compile_const_iterator_"
  13. %{
  14. namespace Standard {
  15. template<class Key, class T> class Multimap {
  16. public:
  17. typedef Key key_type;
  18. typedef T mapped_type;
  19. class iterator {};
  20. class const_iterator {};
  21. // test usage of a typedef of a nested class in a template
  22. Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
  23. Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
  24. };
  25. }
  26. %}
  27. namespace Standard {
  28. template<class Key, class T> class Multimap {
  29. public:
  30. typedef Key key_type;
  31. typedef T mapped_type;
  32. class iterator;
  33. class const_iterator;
  34. // test usage of a typedef of a nested class in a template
  35. Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
  36. Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
  37. };
  38. }
  39. %inline %{
  40. struct A {
  41. int val;
  42. A(int v = 0): val(v) {}
  43. };
  44. %}
  45. %template(PairA) Standard::Pair<int, A*>;
  46. %template(MultimapA) Standard::Multimap<int, A*>;