www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2778] New: alias this + IFTI doesn't work.

http://d.puremagic.com/issues/show_bug.cgi?id=2778

           Summary: alias this + IFTI doesn't work.
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com


DMD 2.027 can't implicitly instantiate templates properly based on implicit
conversions via alias this.

import std.stdio;

struct ArrayWrapper(T) {
    T[] data;
    alias data this;
}

void doStuffTempl(T)(T[] data) {}

void doStuffFunc(int[] data) {}

void main() {
    ArrayWrapper!(int) foo;
    doStuffFunc(foo);  // Works.
    doStuffTempl!(int)(foo);  // Works.

    // Error: template test.doStuffTempl(T) does not match any function
    // template declaration
    // Error: template test.doStuffTempl(T) cannot deduce
    // template function from argument types !()(ArrayWrapper!(int))
    doStuffTempl(foo);
}


-- 
Apr 01 2009