Template specialisation for range of types
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Mar 12 12:32:37 PDT 2017
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.
More information about the Digitalmars-d-learn
mailing list