Document improved template explicit specialization and partial specialization
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11713 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
16b8caa3de
commit
6fc2ce82ea
1 changed files with 23 additions and 6 deletions
|
|
@ -3246,22 +3246,39 @@ public:
|
|||
</div>
|
||||
|
||||
<p>
|
||||
SWIG should be able to handle most simple uses of partial specialization. However, it may fail
|
||||
to match templates properly in more complicated cases. For example, if you have this code,
|
||||
SWIG supports both template explicit specialization and partial specialization. Consider:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
template<class T1, class T2> class Foo<T1, T2 *> { };
|
||||
template<class T1, class T2> class Foo { }; // (1) primary template
|
||||
template<> class Foo<double *, int *> { }; // (2) explicit specialization
|
||||
template<class T1, class T2> class Foo<T1, T2 *> { }; // (3) partial specialization
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
SWIG isn't able to match it properly for instantiations like <tt>Foo<int *, int *></tt>.
|
||||
This problem is not due to parsing, but due to the fact that SWIG does not currently implement all
|
||||
of the C++ argument deduction rules.
|
||||
SWIG is able to properly match explicit instantiations:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
<tt>Foo<double *, int *></tt> // explicit specialization matching (2)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
SWIG implements template argument deduction so that the following partial specialization examples work just like they would with a C++ compiler:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
<tt>Foo<int *, int *></tt> // partial specialization matching (3)
|
||||
<tt>Foo<int *, const int *></tt> // partial specialization matching (3)
|
||||
<tt>Foo<int *, int **></tt> // partial specialization matching (3)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Member function templates are supported. The underlying principle is the same
|
||||
as for normal templates--SWIG can't create a wrapper unless you provide
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue