swig/Examples/test-suite/template_specialization_defarg.i
William S Fulton 4729cf2b1f Duplicate class template instantiations via %template changes
Named duplicate class template instantiations now issue a warning and are ignored.
Duplicate empty class template instantiations are quietly ignored.

The test cases are fixed for this new behaviour.

This commit is a pre-requisite for the near future so that the Python
builtin wrappers can correctly use the SwigType_namestr function without
generating duplicate symbol names.
2022-11-18 19:35:47 +00:00

97 lines
1.2 KiB
OpenEdge ABL

%module template_specialization_defarg
%warnfilter(SWIGWARN_TYPE_REDEFINED) C<double, double>; // note that warning is actually for the equivalent C<double.
%inline %{
template <class A, class B = double>
struct C
{
};
template <class BB>
struct C<int , BB>
{
int hi()
{
return 0;
}
C(int a)
{
}
};
template <class BB>
struct C<double , BB>
{
int hello()
{
return 0;
}
C(double a)
{
}
};
template <class T>
struct Alloc
{
};
template <class T, class A = double >
struct D
{
D(int){}
};
template <>
struct D<double>
{
D(){}
int foo() { return 0; }
};
template <class T, class A = Alloc<T> >
struct Vector
{
Vector(int){}
};
template <>
struct Vector<double>
{
Vector(){}
int foo() { return 0; }
};
%}
//
// This works fine
//
%template(C_i) C<int, double>;
//
// This one fails
//
%template(C_dd) C<double,double>;
%template(C_d) C<double>;
%template(D_i) D<int>;
%template(D_d) D<double>;
%template(Vector_i) Vector<int>;
%template(Vector_d) Vector<double, Alloc<double> >;