1 %module template_class_reuse_name 2 3 // One parameter templates 4 %inline %{ 5 namespace Space { ttBool16 template <bool B> struct Bool1 { void tt(){}; void ff(){}; }; ttBool27 template <bool B = true> struct Bool2 { void tt(){}; void ff(){}; }; 8 template <bool B> struct Bool3 {}; 9 template <> struct Bool3<true> { void tt(){}; }; 10 template <> struct Bool3<false> { void ff(){}; }; 11 template <bool B = true> struct Bool4 { void tt(){}; }; 12 template <> struct Bool4<false> { void ff(){}; }; 13 } 14 %} 15 16 // Instantiated names are the same as C++ template name 17 %template(Bool1) Space::Bool1<true>; 18 %template(Bool2) Space::Bool2<true>; 19 %template(Bool3) Space::Bool3<true>; 20 %template(Bool4) Space::Bool4<true>; 21 22 // Instantiated names are not the same as C++ template name 23 %template(Bool1False) Space::Bool1<false>; 24 %template(Bool2False) Space::Bool2<false>; 25 %template(Bool3False) Space::Bool3<false>; 26 %template(Bool4False) Space::Bool4<false>; 27 28 29 // Forward declared templates 30 %inline %{ 31 namespace Space { 32 template <bool B> struct BoolForward1; 33 template <bool B> struct BoolForward2; 34 template <bool B> struct BoolForward3; 35 template <bool B> struct BoolForward4; 36 37 template <bool B> struct BoolForward1 { void tt(){}; void ff(){}; }; 38 template <bool B = true> struct BoolForward2 { void tt(){}; void ff(){}; }; 39 template <bool B> struct BoolForward3 {}; 40 template <> struct BoolForward3<true> { void tt(){}; }; 41 template <> struct BoolForward3<false> { void ff(){}; }; 42 template <bool B = true> struct BoolForward4 { void tt(){}; }; 43 template <> struct BoolForward4<false> { void ff(){}; }; 44 } 45 %} 46 47 // Instantiated names are the same as C++ template name 48 %template(BoolForward1) Space::BoolForward1<true>; 49 %template(BoolForward2) Space::BoolForward2<true>; 50 %template(BoolForward3) Space::BoolForward3<true>; 51 %template(BoolForward4) Space::BoolForward4<true>; 52 53 // Instantiated names are not the same as C++ template name 54 %template(BoolForward1False) Space::BoolForward1<false>; 55 %template(BoolForward2False) Space::BoolForward2<false>; 56 %template(BoolForward3False) Space::BoolForward3<false>; 57 %template(BoolForward4False) Space::BoolForward4<false>; 58 59 60 // Two parameter templates 61 %inline %{ 62 namespace Space { 63 template <int I, bool B> struct IntBool1 { void tt(){}; void ff(){}; }; 64 template <int I, bool B = true> struct IntBool2 { void tt(){}; void ff(){}; }; 65 template <int I, bool B> struct IntBool3 {}; 66 template <int I> struct IntBool3<I, true> { void tt(){}; }; 67 template <int I> struct IntBool3<I, false> { void ff(){}; }; 68 template <int I, bool B = true> struct IntBool4 { void tt(){}; }; 69 template <int I> struct IntBool4<I, false> { void ff(){}; }; 70 } 71 %} 72 73 // Instantiated names are the same as C++ template name 74 %template(IntBool1) Space::IntBool1<0, true>; 75 %template(IntBool2) Space::IntBool2<0, true>; 76 %template(IntBool3) Space::IntBool3<0, true>; 77 %template(IntBool4) Space::IntBool4<0, true>; 78 79 // Instantiated names are not the same as C++ template name 80 %template(IntBool1False) Space::IntBool1<0, false>; 81 %template(IntBool2False) Space::IntBool2<0, false>; 82 %template(IntBool3False) Space::IntBool3<0, false>; 83 %template(IntBool4False) Space::IntBool4<0, false>; 84 85 86 %{ 87 namespace Space { 88 template <bool B> struct Duplicate1 { void ff(){}; }; 89 } 90 %} 91 92 %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate1; 93 namespace Space { 94 template <bool B> struct Duplicate1 { void ff(){}; }; 95 template <bool B> struct Duplicate1 { void ff(){}; }; 96 } 97 98 99 %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate2; 100 %inline %{ 101 namespace Space { 102 template <int I> struct Duplicate2 { void n(){}; }; 103 } 104 %} 105 %template(Duplicate2_0) Space::Duplicate2<0>; 106 %template(Duplicate2_0) Space::Duplicate2<0>; 107 108 109 %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate3; 110 %inline %{ 111 namespace Space { 112 template <int I> struct Duplicate3 { void n(){}; }; 113 } 114 %} 115 %template(Duplicate3) Space::Duplicate3<0>; 116 %template(Duplicate3) Space::Duplicate3<0>; 117 118 119 %{ 120 namespace Space { 121 template <bool B> struct Duplicate4 { void ff(){}; }; 122 } 123 %} 124 125 %warnfilter(SWIGWARN_PARSE_REDEFINED) Space::Duplicate4; 126 namespace Space { 127 template <bool B> struct Duplicate4 { void ff(){}; }; 128 template <bool B> struct Duplicate4 { void ff(){}; }; 129 } 130 %template(Duplicate4) Space::Duplicate4<0>; 131 %template(Duplicate4) Space::Duplicate4<0>; 132 133