Update variadic templates
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@13863 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b9fd49858d
commit
6a43934ece
2 changed files with 20 additions and 11 deletions
|
|
@ -500,7 +500,7 @@ union P {
|
||||||
<H3><a name="Cpp0x_Variadic_templates"></a>7.2.17 Variadic templates</H3>
|
<H3><a name="Cpp0x_Variadic_templates"></a>7.2.17 Variadic templates</H3>
|
||||||
|
|
||||||
|
|
||||||
<p>SWIG fully supports the variadic templates syntax (inside the <>
|
<p>SWIG supports the variadic templates syntax (inside the <>
|
||||||
block, variadic class inheritance and variadic constructor and
|
block, variadic class inheritance and variadic constructor and
|
||||||
initializers) with some limitations. The following code is correctly parsed:</p>
|
initializers) with some limitations. The following code is correctly parsed:</p>
|
||||||
|
|
||||||
|
|
@ -517,11 +517,13 @@ public:
|
||||||
const int SIZE = sizeof...(ClassName<int, int>);
|
const int SIZE = sizeof...(ClassName<int, int>);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
||||||
<p>For now however, the <tt>%template</tt> directive only accepts at most the number of
|
<p>
|
||||||
arguments defined in the original template<> block:</p>
|
For now however, the <tt>%template</tt> directive only accepts one parameter substitution
|
||||||
|
for the variable template parameters.
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="code"><pre>
|
<div class="code"><pre>
|
||||||
%template(MyVariant1) ClassName<> // ok
|
%template(MyVariant1) ClassName<> // zero argument not supported
|
||||||
%template(MyVariant2) ClassName<int> // ok
|
%template(MyVariant2) ClassName<int> // ok
|
||||||
%template(MyVariant3) ClassName<int, int> // too many arguments
|
%template(MyVariant3) ClassName<int, int> // too many arguments
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
using variadic number of classes.
|
using variadic number of classes.
|
||||||
*/
|
*/
|
||||||
%module cpp0x_variadic_templates
|
%module cpp0x_variadic_templates
|
||||||
%warnfilter(507) MultiArgs1;
|
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiArgs;
|
||||||
%warnfilter(507) SizeOf1;
|
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) SizeOf;
|
||||||
%warnfilter(507) MultiInherit1;
|
%warnfilter(SWIGWARN_CPP11_VARIADIC_TEMPLATE) MultiInherit;
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Variadic templates //
|
// Variadic templates //
|
||||||
|
|
@ -36,7 +36,6 @@ template<typename... Args> struct SizeOf {
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
// TODO
|
|
||||||
%template (SizeOf1) SizeOf<int, int>;
|
%template (SizeOf1) SizeOf<int, int>;
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
@ -48,7 +47,7 @@ public:
|
||||||
A() {
|
A() {
|
||||||
a = 100;
|
a = 100;
|
||||||
}
|
}
|
||||||
|
virtual ~A() {}
|
||||||
int a;
|
int a;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -57,14 +56,22 @@ public:
|
||||||
B() {
|
B() {
|
||||||
b = 200;
|
b = 200;
|
||||||
}
|
}
|
||||||
|
virtual ~B() {}
|
||||||
int b;
|
int b;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... BaseClasses> class MultiInherit : public BaseClasses... {
|
template <typename... BaseClasses> class MultiInherit : public BaseClasses... {
|
||||||
public:
|
public:
|
||||||
MultiInherit(BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
MultiInherit(BaseClasses&... baseClasses) : BaseClasses(baseClasses)... {}
|
||||||
|
int InstanceMethod() { return 123; }
|
||||||
|
static int StaticMethod() { return 456; }
|
||||||
};
|
};
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
%template (MultiInherit1) MultiInherit<A,B>;
|
//%template (MultiInherit0) MultiInherit<>;
|
||||||
|
%template (MultiInherit1) MultiInherit<A>;
|
||||||
|
// TODO
|
||||||
|
%template (MultiInherit2) MultiInherit<A,B>;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue