This problem might have been raised before, but I can't why this doesn't compile (except the last line), while a non-template version of the same code works well. Is this a bug?

---
module test;

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
    graph.add_edge!(string)("A", "B");  // Error
    add_edge(graph, "A", "B");          // Error
    add_edge!(string)(graph, "A", "B"); // OK
}
---

DMD 2.040, Mac OS X

Thanks,
Nicolas

Reply via email to