You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/documentation/building_a_simulation/Model-Source-Code.md
+43-16Lines changed: 43 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -408,24 +408,51 @@ Trick may use model code with any type of inheritance. Some limitations are pres
408
408
409
409
### Namespaces
410
410
411
-
Currently one level of namespace is supported. Additional levels of namespaces are ignored. Similarly classes and enumerations embedded in other classes are ignored.
411
+
ICG supports namespaces and nested scopes. Data recording and variable access via Trick View should work regardless of how many levels there are.
412
412
413
-
```C++
414
-
namespacemy_ns {
415
-
// BB is processed
416
-
class BB {
417
-
public:
418
-
std::string str;
419
-
// Class CC is ignored.
420
-
class CC {
421
-
...
413
+
Namespaces and nested scopes are similarly supported in Python contexts, such as the input file and variable server, with some caveats regarding templates.
414
+
1. A template instantiation may be unqualified (have no use of the scope resolution operator `::`) only if its corresponding template is declared in the immediately-enclosing namespace.
415
+
2. Otherwise, a template instantiation must be fully qualified, starting from the global namespace.
416
+
3. Finally, instantiations of templates declared within the same class must be excluded from SWIG.
417
+
418
+
In the following examples, all template instantiations occur in `example::prime::Soup`. The immediately-enclosing namespace is `prime`, so only instantiations of templates declared directly in `prime` (only `Celery`) may be unqualified. All other template instantiations must be fully qualified, starting from the global namespace, even if the C++ name lookup process would find them with partial qualification.
0 commit comments