diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 62c0e8d1e..eeca0291c 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3614,18 +3614,52 @@ and the second will take two integer arguments.

-Needless to say, SWIG's template support provides plenty of -opportunities to break the universe. That said, an important final -point is that SWIG does not perform extensive error checking of -templates! Specifically, SWIG does not perform type checking nor -does it check to see if the actual contents of the template -declaration make any sense. Since the C++ compiler will hopefully -check this when it compiles the resulting wrapper file, there is no -practical reason for SWIG to duplicate this functionality (besides, -none of the SWIG developers are masochistic enough to want to -implement this right now). +Needless to say, SWIG's template support provides plenty of opportunities to +break the universe. That said, an important final point is that SWIG does +not perform extensive error checking of templates! Specifically, SWIG does +not perform type checking nor does it check to see if the actual contents of the +template declaration make any sense. Since the C++ compiler checks this when it +compiles the resulting wrapper file, there is no practical reason for SWIG to +duplicate this functionality.

+ +

+As SWIG's template support does not perform type checking %template +can be used as early as after a template declaration. You can, and rarely have +to, use %template before the template parameters have been declared. +For example: +

+ +
+
+template <class T> class OuterTemplateClass {};
+
+// The nested class OuterClass::InnerClass inherits from the template class
+// OuterTemplateClass<OuterClass::InnerStruct> and thus the template needs
+// to be expanded with %template before the OuterClass declaration.
+%template(OuterTemplateClass_OuterClass__InnerStruct)
+    OuterTemplateClass<OuterClass::InnerStruct>
+
+
+// Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and
+// OuterClass::InnerClass if the target language doesn't support nested classes.
+class OuterClass {
+    public:
+        // Forward declarations:
+        struct InnerStruct;
+        class InnerClass;
+};
+
+struct OuterClass::InnerStruct {};
+
+// Expanding the template at this point with %template is too late as the
+// OuterClass::InnerClass declaration is processed inside OuterClass.
+
+class OuterClass::InnerClass : public OuterTemplateClass<InnerStruct> {};
+
+
+

Compatibility Note: The first implementation of template support relied heavily on macro expansion in the preprocessor. Templates have been more tightly integrated into @@ -5000,6 +5034,12 @@ class Bar { +

+If a nested class, within an outer class, has to be used as a template parameter within the outer class, then the template will +have to be instantiated with %template before the beginning of the outer class. +An example can be found in the +Templates section. +

Compatibility Note: