[Issue 11706] New: Alias to the original type inside std.typecons.Typedef

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 7 07:20:42 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11706

           Summary: Alias to the original type inside std.typecons.Typedef
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-12-07 07:20:40 PST ---
In dmd 2.065alpha this code doesn't work (see Issue 11704 ):


void main() {
    import std.typecons: Typedef;
    import std.conv: to;
    alias T = Typedef!int;
    string x = "5";
    T y = to!T(x);
}


A workaround is:

T y = T(to!int(x));

A problem with this work-around is that "int" needs to be repeated, it's not
DRY.

So I suggest to add to Typedef an alias of the underlying type, so you can
write:

T y = T(to!(T.originalType)(x));

This alias is useful for other cases.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list