On Sunday, 12 March 2017 at 19:32:37 UTC, ketmar wrote:
data pulverizer wrote:

In this case would like to use the ConstOf specialisation instead of the default implementation for the inputs which are const.

actually, second template is uninstantiable at all. you want to do type deconstruction at instantiation, and that doesn't work.

i.e. what your code wants to do (as it is written) is to have `T` in second template to be equal to `double`. you cannot deconstruct the type like that in template. what you *can* do, though, is this:

 auto max(T)(const(T)* x, const(T)* y)

this way it will select your second template.

If I change the implementation of the second template to your above declaration, I get the error:

max.max called with argument types (const(double)*, const(double)*) matches both: max.d(34): max.max!(const(double)*).max(const(double)* x, const(double)* y)
and:
max.d(42): max.max!double.max(const(double)* x, const(double)* y)

I need at least those two implementation for the different cases, a general "default", and for specified types and type qualifications.

Reply via email to