www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 568] New: Support to implicitly deduce class template in function template

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

           Summary: Support to implicitly deduce class template in function
                    template
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: lovesyao hotmail.com


class Test(T){
  T t=T.init;
}

class Test2:Test!(int){};

interface Test3(T){
  static if(is(T==int)){
    T i();
  }else{
    T other();
  }
}

class Test4:Test3!(int),Test3!(float){
  int i(){return 0;};
  float other(){return 0.0;};
};

void test(T)(Test!(T) t){
}

void test2(T)(Test3!(T) t){
}

void main(){
  auto t=new Test!(int);
  auto t2=new Test2;
  auto t3=new Test4;

  test!(int)(t);//ok
  test!(int)(t2);//ok
  test2!(int)(t3);//ok
  test2!(float)(t3);//ok
  test(t);//please support
  test(t2);//please support
  test2(t3);//should be conflict error
}


-- 
Nov 18 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=568





------- Comment #1 from lovesyao hotmail.com  2006-11-18 19:28 -------
add example

template Test5(T){
  alias int dummy;
  class Test5(T t){
    T val=t;
  }
};

template test3(T){
  alias int dummy;
  void test3(T t)(Test5!(T).Test5!(t) t){

  }
}

void main(){
  auto t = new Test5!(int).Test5!(10);
  test3!(int).test3!(10)(t);//ok
  test3(t);//please support
}


-- 
Nov 18 2006
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=568


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei metalanguage.com
         Resolution|                            |FIXED


--- Comment #2 from Andrei Alexandrescu <andrei metalanguage.com> 2010-11-26
12:06:46 PST ---
First round of examples now work on 1.065 and 2.050. The second round is
invalid.

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