generic + numeric + literals = abomination

biozic dransic at free.fr
Sun Mar 28 07:09:21 PDT 2010


Le 28/03/10 10:57, so a écrit :
> Well, i am having hard time explaining, it is not a surprise that you
> don't understand.
> To make things clearer, lets forget floats for a seconds and change your
> code to standard unsigned types.
>
>
> import std.stdio: writeln;
>
> struct Vector(T) {
> this(T m) { mm = m; }
> Vector opBinary(string op:"*", T2)(T2 m) if(is(T2 == T)) {
> return Vector(mm * m);
> }
> T mm;
> }

Have you checked std.traits, where isIntegral!T, isFloatingPoint!T, etc. 
are defined? Could these, used as template constraints, solve your problem?



More information about the Digitalmars-d-learn mailing list