[Issue 11706] std.traits.OriginalType should support std.typecons.Typedef

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Apr 24 04:10:11 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #5 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
(In reply to bearophile_hugs from comment #4)
> (In reply to Andrej Mitrovic from comment #3)
> > https://github.com/D-Programming-Language/phobos/pull/2116
> 
> Thank you. But:
> 
> > // safely cast to get the value that's being wrapped
> > int x = cast(OriginalType!MyInt)myInt;
> 
> casts are not safe. That example is not good.
> 
> Safer and shorter:
> 
> int x = myInt.get;

That's not safer if 'myInt' is a UDT that happens to define get(). You may end
up calling a function that returns something else entirely.

--


More information about the Digitalmars-d-bugs mailing list