On 2015-07-04 14:52, David Vierra wrote:
> Cython is unable to deduce the type parameters for that function call
> because the type of the second argument is different (size_t vs long).
> It should implicitly convert the argument as C++ does, but it looks like
> a bug makes it abort template deduction when the type of the
> non-template argument doesn't match.
>
> `get(c, <size_t>1)` ought to work.
Hi David,
that did it! Thanks for investigating this. I have in the meantime
posted the question on Stackoverflow, perhaps you would like to copy
your answer there:
http://stackoverflow.com/questions/31201382/
I saw just now a comment there that specifying the type parameter
explicitly as in 'get[int](c, 1)' also works. It does, but in reality, I
have multiple type parameters and I’d like to avoid having to type it
all out, so I prefer your suggestion.
> Details:
>
> In best_type(), PyrexTypes.py:3991, it calls
> `pattern.type.deduce_template_params(actual)`, where `pattern.type` is
> `size_t` and `actual` is `long`. The call to `deduce_template_params`
> calls the function of BaseType, which returns None if the two types are
> not exactly equal, which gets passed through merge_template_deductions
> and triggers the `if deductions is None:` on the next line.
>
> Maybe `BaseType.deduce_template_params` should return {} if the two
> types are convertible, since later on in `best_type()`, the (overloaded)
> candidate functions are ranked by implicit conversions.
I see: When I temporarily change the size_t in the declaration of get()
to long, Cython also accepts it. I have looked at the code now for a
while, but I cannot propose a patch myself, so perhaps one of the
developers has time.
Thanks again,
Marcel