www.digitalmars.com         C & C++   DMDScript  

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

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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Dec 07 2013