Fix #1819847 %template with just one default template parameter
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10189 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a84f3dfa68
commit
b79ebf39fa
8 changed files with 117 additions and 11 deletions
|
|
@ -264,6 +264,7 @@ CPP_TEST_CASES += \
|
|||
template_default \
|
||||
template_default2 \
|
||||
template_default_arg \
|
||||
template_default_class_parms \
|
||||
template_default_inherit \
|
||||
template_default_qualify \
|
||||
template_default_vw \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
|
||||
|
||||
import template_default_class_parms.*;
|
||||
|
||||
public class template_default_class_parms_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_default_class_parms");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
|
||||
double d = bar.getCType();
|
||||
SomeType s = bar.getDType();
|
||||
int i = bar.getEType();
|
||||
d = bar.method(d, s, i);
|
||||
}
|
||||
{
|
||||
DefaultFoo foo = new DefaultFoo(new SomeType());
|
||||
SomeType s = foo.getTType();
|
||||
s = foo.method(s);
|
||||
}
|
||||
{
|
||||
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
|
||||
AnotherType a = bar.getCType();
|
||||
boolean b = bar.getDType();
|
||||
int i = bar.getEType();
|
||||
a = bar.method(a, b, i);
|
||||
}
|
||||
{
|
||||
FooAnotherType foo = new FooAnotherType(new AnotherType());
|
||||
AnotherType a = foo.getTType();
|
||||
a = foo.method(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
Examples/test-suite/template_default_class_parms.i
Normal file
33
Examples/test-suite/template_default_class_parms.i
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
%module template_default_class_parms
|
||||
|
||||
%inline %{
|
||||
namespace Space {
|
||||
struct SomeType {};
|
||||
struct AnotherType {};
|
||||
template<typename C, typename D = SomeType, typename E = int> class Bar {
|
||||
public:
|
||||
C CType;
|
||||
D DType;
|
||||
E EType;
|
||||
Bar(C c, D d, E e) {}
|
||||
C method(C c, D d, E e) { return c; }
|
||||
};
|
||||
template<typename T = SomeType> class Foo {
|
||||
public:
|
||||
T TType;
|
||||
Foo(T t) {}
|
||||
T method(T t) { return t; }
|
||||
};
|
||||
template<typename T = int> class ATemplate {};
|
||||
}
|
||||
%}
|
||||
|
||||
// Use defaults
|
||||
%template(DefaultBar) Space::Bar<double>;
|
||||
%template(DefaultFoo) Space::Foo<>;
|
||||
|
||||
// Don't use all defaults
|
||||
%template(BarAnotherTypeBool) Space::Bar<Space::AnotherType, bool>;
|
||||
%template(FooAnotherType) Space::Foo<Space::AnotherType>;
|
||||
|
||||
%template() Space::ATemplate<>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue