summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2022-03-04 16:36:04 +1300
committerOlly Betts <olly@survex.com>2022-03-04 16:36:04 +1300
commit8f54f6180aa63f747c0d6c10726e01d995a1ad07 (patch)
tree7c947f526a9baac16e69b3d081d9ff500e0c2a4f
parent713438e8791c22c31e8ffad55b4d4d7d3fa757d1 (diff)
downloadswig-8f54f6180aa63f747c0d6c10726e01d995a1ad07.tar.gz
Update docs for expression parsing improvements
-rw-r--r--Doc/Manual/SWIGPlus.html16
-rw-r--r--Examples/test-suite/constant_expr.i4
2 files changed, 13 insertions, 7 deletions
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index 42c4fcea6..4cefdc365 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -3057,22 +3057,24 @@ is expected in an interface file. For example:
<div class="code">
<pre>
void foo(vector&lt;int&gt; *a, int n);
-void bar(list&lt;int, 100&gt; *x);
+void bar(std::array&lt;int, 100&gt; *x);
</pre>
</div>
<p>
There are some restrictions on the use of non-type arguments. Simple literals
-are supported, and so are some constant expressions. However, use of '&lt;'
-and '&gt;' within a constant expressions currently is not supported by SWIG
-('&lt;=' and '&gt;=' are though). For example:
+are supported, and so are most constant expressions. However, there are some
+limitations on the use of '&lt;' and '&gt;' in constant expressions (but note
+that '&lt;=' and '&gt;=' are fully supported). For example:
</p>
<div class="code">
<pre>
-void bar(list&lt;int, 100&gt; *x); // OK
-void bar(list&lt;int, 2*50&gt; *x); // OK
-void bar(list&lt;int, (2&gt;1 ? 100 : 50)&gt; *x) // Not supported
+void bar(std::array&lt;int, 100&gt; *x); // OK
+void bar(std::array&lt;int, 2*50&gt; *x); // OK
+void bar(std::array&lt;int, (1&lt;2 ? 100 : 50)&gt; *x) // OK
+void bar(std::array&lt;int, 1&lt;2 ? 100 : 50&gt; *x) // Not supported
+void bar(std::array&lt;int, (2&gt;1 ? 100 : 50)&gt; *x) // Not supported
</pre>
</div>
diff --git a/Examples/test-suite/constant_expr.i b/Examples/test-suite/constant_expr.i
index 0a9984055..43612b90b 100644
--- a/Examples/test-suite/constant_expr.i
+++ b/Examples/test-suite/constant_expr.i
@@ -23,4 +23,8 @@ isPointer = false
int a;
int test2(int b = 9%a) { return b; }
+/* Example from manual. */
+#include <array>
+void bar(std::array<int, (1<2? 100 : 50)> *x) { }
+
%}