From 8f54f6180aa63f747c0d6c10726e01d995a1ad07 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Mar 2022 16:36:04 +1300 Subject: [PATCH] Update docs for expression parsing improvements --- Doc/Manual/SWIGPlus.html | 16 +++++++++------- Examples/test-suite/constant_expr.i | 4 ++++ 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:
 void foo(vector<int> *a, int n);
-void bar(list<int, 100> *x);
+void bar(std::array<int, 100> *x);
 

There are some restrictions on the use of non-type arguments. Simple literals -are supported, and so are some constant expressions. However, use of '<' -and '>' within a constant expressions currently is not supported by SWIG -('<=' and '>=' are though). For example: +are supported, and so are most constant expressions. However, there are some +limitations on the use of '<' and '>' in constant expressions (but note +that '<=' and '>=' are fully supported). For example:

-void bar(list<int, 100> *x);                // OK
-void bar(list<int, 2*50> *x);               // OK
-void bar(list<int, (2>1 ? 100 : 50)> *x)    // Not supported
+void bar(std::array<int, 100> *x);                // OK
+void bar(std::array<int, 2*50> *x);               // OK
+void bar(std::array<int, (1<2 ? 100 : 50)> *x)    // OK
+void bar(std::array<int, 1<2 ? 100 : 50> *x)      // Not supported
+void bar(std::array<int, (2>1 ? 100 : 50)> *x)    // Not supported
 
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 +void bar(std::array *x) { } + %}