← Back to team overview

dolfin team mailing list archive

Re: SWIG + templates

 

> Is there a way to explicitly instantiate template functions in the C++
> code so that SWIG can use them? I've messed around with this in
> File.h/cpp but can't get it to work.

This should be possible.

Depending on what the final syntax should be, we can do this in different
ways.

However the instantiation principle is more or less the same as for class
templates:

  %extend Foo {
       %template(barint)    bar<int>;
       %template(bardouble) bar<double>;
  };

or just

  %template(bari) Foo::bar<int>;
  %template(bard) Foo::bar<double>;

These should be added in a dolfin_io_pre.i or something. But I assume we
want to hide the actuall function name for the user and extend the python
proxy class with twogeneral __rshift__ and __lshift__ functions, which
each calls the right instantiated template function, dependent on the type
of the "other".

I can probably fix this but not untill a time out in july.

Johan

>
> Garth
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev
>




References