www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3904] New: Infer function type from an alias in a template

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

           Summary: Infer function type from an alias in a template
           Product: D
           Version: 2.041
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



I think the compiler can infer the type here:


template Type(T) { alias T Type; }
void bar(T)(Type!T t) {}
void main() {
    int b = 1;
    bar!int(b); // OK
    bar(b); // template test.bar(T) does not match any function template
declaration
}


Problem found by Nicolas / biozic:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=19054


The original code was:

template Graph(T) {
     alias T[][T] Graph;
}
void add_edge(T)(ref Graph!(T) graph, T source, T target) {
     graph[source] ~= target;
}
void main() {
     Graph!(string) graph;
     graph.add_edge("A", "B"); // Error
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3904


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |schveiguy yahoo.com
         Resolution|                            |DUPLICATE



04:15:46 PST ---
*** This issue has been marked as a duplicate of issue 1807 ***

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