[Issue 3904] New: Infer function type from an alias in a template
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 8 15:27:22 PST 2010
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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list