An idiom for disabling implicit conversions
bearophile
bearophileHUGS at lycos.com
Fri Mar 19 02:20:20 PDT 2010
Don:
Do you know why this semantics:
> void add(Tulong)(Tulong x) if ( is(Tulong == ulong) )
Is different from this one?
void add(Tulong:ulong)(Tulong x) {
This page says:
http://www.digitalmars.com/d/2.0/templates-revisited.html
T:int, // T must be int type
So it seems the same as the version with the template constraint.
Can't the D2 semantics of (Tulong:ulong) be redefined to become the same of the version with template constraint if(is(Tulong==ulong)) to remove this special case from D?
> Template constraints are seriously cool.
I agree :-) And Andrei has used them a lot in Phobos2.
Thank you for your trick (but but the idea is to have a language that needs as few tricks as possible).
Bye,
bearophile
More information about the Digitalmars-d
mailing list