[Issue 12597] Payload getter for std.typecons.Typedef

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Sep 24 14:26:33 PDT 2014


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

monkeyworks12 at hotmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monkeyworks12 at hotmail.com

--- Comment #11 from monkeyworks12 at hotmail.com ---
I think this enhancement request should be closed now that
https://github.com/D-Programming-Language/phobos/pull/2116 has been merged.
With that PR, your first example now becomes:

void main() {
    import std.typecons: Typedef;
    import std.math: sin;
    alias Angle = Typedef!double;
    Angle x = 0.5;
    auto y1 = sin(x); // Error.
    auto y2 = sin(cast(TypedefType!Angle)x); // OK.
}

A bit verbose, but it accomplishes what you want and is more DRY and safer than
cast(double)x.

--


More information about the Digitalmars-d-bugs mailing list