generic + numeric + literals = abomination
so
so at so.do
Sun Mar 28 02:37:59 PDT 2010
You didn't change anything there, just back to original code, now just
enabled implicit cast again!
Please read my next replies, everything should be clear now. :)
Thanks!
On Sun, 28 Mar 2010 14:32:21 +0400, bearophile <bearophileHUGS at lycos.com>
wrote:
> so:
>
>> Well, i am having hard time explaining, it is not a surprise that you
>> don't understand.
>
> I think I have understood you this time. Writing skills are important
> for a programmer :-)
> Is this what you are asking for? But it's not very good code:
>
> import std.stdio: writeln;
>
> struct Vector(T) {
> this(T m) { mm = m; }
> this(int m) { mm = cast(T)m; }
> Vector opBinary(string op:"*", T2)(T2 m) {
> return Vector(mm * m);
> }
> T mm;
> }
>
> void test(T)() {
> auto v = Vector!T(5);
> auto u = v * 3;
> writeln("u: ", u.mm);
> }
>
> void main() {
> test!ubyte();
> test!ushort();
> test!uint();
> test!ulong();
> }
>
> Bye,
> bearophile
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Digitalmars-d-learn
mailing list