www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12386] New: Allow using derivatives of IFTI'd types in remaining arguments

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12386

           Summary: Allow using derivatives of IFTI'd types in remaining
                    arguments
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thecybershadow gmail.com



07:37:26 EET ---
//////// test.d ////////
alias X(T) = T;

void f(T)(T a, X!T b) {}

void main()
{
    f(5, 5);
}
////////////////////////

Once the compiler knows what type T is, it can also know what X!T is.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 16 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12386




07:50:51 EET ---
This doesn't work as one might expect:

void f(T, U=X!T)(T a, U b) {}

U will always be inferred from the type of b, overriding the default.

Valid workaround:

void f(T, U)(T a, U b) if(is(U==X!T)) {}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 16 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12386




09:06:58 EET ---
The above workaround doesn't work for certain cases:

alias X(T) = T;

void f(T, U)(T a, U b) if(is(U : X!T)) { }

void main()
{
    ubyte b = 5;
    f(b, 5);
}

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