On Jan 31, 2012 4:57 AM, "Kris Thielemans" <kris.f.thielemans@gmail.com> wrote:
>
> Hi Jim
> >
> > If I have multiple templated functions with the same name and same
> > template parameters, but different signatures, is there any way to
> > instantiate those templates with different types?
> >
> > Here's an example:
> >
> > template <typename T>
> > struct int_thing;
> >
> > template <typename T>
> > struct float_thing;
> >
> > template <typename T>
> > void func(int_thing<T> * t);
> >
> > template <typename T>
> > void func(float_thing<T> * t);
> >
> > I'd like to do the %template equivalent of the following C++ explicit
> > instantiations:
> >
> > template void func(int_thing<int> *);
> > template void func(int_thing<long> *);
> >
> > template void func(float_thing<float> *);
> > template void func(float_thing<double> *);
> >
> > Is there any way to do this?
> >
> >
> I'm confused. You can use %template for multiple types for classes, e.g.
>
>   %template(IntVector) vector<int>;
>   %template(DoubleVector) vector<double>;
>
> Why does this not work for you? If you're getting an error, it'd be good to
> include your swig code and error log.
>

The problem is that "func" isn't a template class, it's an overloaded template function.  When I say:

%template(func) func<int>;

Swig generates wrappers for both (void func(int_thing<int>*)) and (void func(float_thing<int>*)), and the latter isn't valid.

Jim