Fix deduction of partially specialized template parameters

when the specialized parameter is non-trivial, used in a wrapped method
and the type to %template uses typedefs. For example:

  typedef double & DoubleRef;
  template <typename T> struct XX {};
  template <typename T> struct XX<T &> { void fn(T t) {} };
  %template(XXD) XX<DoubleRef>;

The type of the parameter in the instantiated template for fn is now correctly deduced
as double.
This commit is contained in:
William S Fulton 2023-01-14 23:40:02 +00:00
commit bd2de6fc06
4 changed files with 43 additions and 25 deletions

View file

@ -452,10 +452,12 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab
ptype = Getattr(p, "type");
tptype = Getattr(tp, "type");
if (ptype && tptype) {
partial_type = partial_arg(tptype, ptype);
SwigType *ty = Swig_symbol_typedef_reduce(tptype, tscope);
partial_type = partial_arg(ty, ptype);
/* Printf(stdout,"partial '%s' '%s' ---> '%s'\n", tptype, ptype, partial_type); */
Setattr(tp, "type", partial_type);
Delete(partial_type);
Delete(ty);
}
p = nextSibling(p);
tp = nextSibling(tp);