March 08, 2010 [Issue 3904] New: Infer function type from an alias in a template | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from bearophile_hugs@eml.cc 2010-03-08 15:27:19 PST --- 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: ------- |
March 09, 2010 [Issue 3904] Infer function type from an alias in a template | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | 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 --- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-03-09 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: ------- |
Copyright © 1999-2021 by the D Language Foundation