summaryrefslogtreecommitdiff
path: root/Examples/test-suite/template_typedef_class_template.i
blob: fc8151ff0f17be5bc405a2bc64720aebfe8e7817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
%module template_typedef_class_template

%inline %{
namespace Standard {
  template <class T, class U > struct Pair {
    T first;
    U second;
  };
}
%}

// previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap
%typemap(out) Standard::Pair<Standard::iterator, Standard::iterator> "_this_will_not_compile_iterator_"
%typemap(out) Standard::Pair<Standard::const_iterator, Standard::const_iterator> "_this_will_not_compile_const_iterator_"

%{
namespace Standard {
template<class Key, class T> class Multimap {
  public:
    typedef Key key_type;
    typedef T mapped_type;

    class iterator {};
    class const_iterator {};

    // test usage of a typedef of a nested class in a template
    Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) { return Standard::Pair<iterator,iterator>(); }
    Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const { return Standard::Pair<const_iterator,const_iterator>(); }
  };
}
%}

namespace Standard {
template<class Key, class T> class Multimap {
  public:
    typedef Key key_type;
    typedef T mapped_type;

    class iterator;
    class const_iterator;

    // test usage of a typedef of a nested class in a template
    Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
    Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
  };
}

%inline %{
struct A {
    int val;
    A(int v = 0): val(v) {}
};
%}

%template(PairA) Standard::Pair<int, A*>;
%template(MultimapA) Standard::Multimap<int, A*>;