PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 2ms 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
 1%module template_typedef_class_template
 2
 3%inline %{
 4namespace Standard {
 5  template <class T, class U > struct Pair {
 6    T first;
 7    U second;
 8  };
 9}
10%}
11
12// previously these typemaps were erroneously being used as iterator was not correctly scoped in Multimap
13%typemap(out) Standard::Pair<Standard::iterator, Standard::iterator> "_this_will_not_compile_iterator_"
14%typemap(out) Standard::Pair<Standard::const_iterator, Standard::const_iterator> "_this_will_not_compile_const_iterator_"
15
16%{
17namespace Standard {
18template<class Key, class T> class Multimap {
19  public:
20    typedef Key key_type;
21    typedef T mapped_type;
22
23    class iterator {};
24    class const_iterator {};
25
26    // test usage of a typedef of a nested class in a template
27    Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
28    Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
29  };
30}
31%}
32
33namespace Standard {
34template<class Key, class T> class Multimap {
35  public:
36    typedef Key key_type;
37    typedef T mapped_type;
38
39    class iterator;
40    class const_iterator;
41
42    // test usage of a typedef of a nested class in a template
43    Standard::Pair<iterator,iterator> equal_range_1(const key_type& kt1) {}
44    Standard::Pair<const_iterator,const_iterator> equal_range_2(const key_type& kt2) const {}
45  };
46}
47
48%inline %{
49struct A {
50    int val;
51    A(int v = 0): val(v) {}
52};
53%}
54
55%template(PairA) Standard::Pair<int, A*>;
56%template(MultimapA) Standard::Multimap<int, A*>;
57