summaryrefslogtreecommitdiff
path: root/Examples/test-suite/cpp11_alias_nested_template_scoping.i
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-17 17:10:46 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-02-17 20:03:18 +0000
commit629c881de507b29cb9be5b98ceb3a016aacd474a (patch)
tree3966f98d497c14c5149084c10c5d37decf91703c /Examples/test-suite/cpp11_alias_nested_template_scoping.i
parentde861bea6481f2b44f4ca908ea378b093e29924d (diff)
downloadswig-629c881de507b29cb9be5b98ceb3a016aacd474a.tar.gz
Template instantion fixes when template parameter is used twice in type
For example T in: Y<T>::YYY<T>::value_type
Diffstat (limited to 'Examples/test-suite/cpp11_alias_nested_template_scoping.i')
-rw-r--r--Examples/test-suite/cpp11_alias_nested_template_scoping.i45
1 files changed, 45 insertions, 0 deletions
diff --git a/Examples/test-suite/cpp11_alias_nested_template_scoping.i b/Examples/test-suite/cpp11_alias_nested_template_scoping.i
new file mode 100644
index 000000000..0cf5ea35a
--- /dev/null
+++ b/Examples/test-suite/cpp11_alias_nested_template_scoping.i
@@ -0,0 +1,45 @@
+%module cpp11_alias_nested_template_scoping
+
+// Test to check a template parameter type is expanded when the template parameter
+// is used twice in a type name. Expansion was
+// Y< short >::YYY< T >::value_type >
+// instead of
+// Y< short >::YYY< short >::value_type >
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested") ZZZ;
+#endif
+
+%inline %{
+template<typename T> struct Y {
+ typedef T value_type;
+ typedef Y YY;
+ template<typename T2> using YYY = Y<T2>;
+ template<typename T2> struct ZZZ {
+ typedef T2 another_type;
+ };
+ value_type create1() const { return T(); }
+ Y::value_type create2() const { return T(); }
+ Y<T>::value_type create3() const { return T(); }
+ YY::value_type create4() const { return T(); }
+ Y<T>::YY::value_type create5() const { return T(); }
+ Y<T>::YYY<T>::value_type create6() const { return T(); }
+ typename Y<T>::template ZZZ<T>::another_type create7() const { return T(); }
+
+ // With global scope prefix
+ ::Y<T>::value_type create13() const { return T(); }
+
+ ::Y<T>::YY::value_type create15() const { return T(); }
+ ::Y<T>::YYY<T>::value_type create16() const { return T(); }
+ typename ::Y<T>::template ZZZ<T>::another_type create17() const { return T(); }
+};
+%}
+
+%extend Y {
+%template() YYY<short>;
+%template() ZZZ<short>;
+};
+// Use above workaround instead of below (which currently gives syntax error)
+// %template() Y<short>::YYY<short>;
+
+%template(Yshort) Y<short>;