You need to use a template constraint.
pure T[] mul(S, T)(S s, T[] a) if (isScalarType!S)
This declares that the template should only be considered when isScalarType!S
is true
.
isScalarType
can be found in std.traits
.
In D, the scalar types are the numeric types, character types, and bool
. You can restrict further using the other traits from std.traits
if you like (e.g. isNumeric
or isFloatingPoint
).