Templated function as associative array property
Nicolas
biozic at free.fr
Mon Mar 8 05:37:18 PST 2010
bearophile Wrote:
> biozic:
> > Yes, it works, thanks! But I believe this is just a workaround hack.
>
> It's a workaround but it's not a hack. If no one else answers you then you can add a bug to bugzilla... (I am not sure it's a real bug).
Yes, you're right.
I think the problem can eventually be reduced to the following simple things:
---
module test;
void foo(T)(T[] array) {}
template Type(T) { alias T Type; }
void bar(T)(Type!T t) {}
void main()
{
int[] a = [1, 2, 3];
foo(a); // OK
foo!int(a); // OK
a.foo(); // OK
//a.foo!int(); // Error: foo(a) isn't a template
int b = 1;
bar!int(b); // OK
bar(b); // Error (template deduction fails)
}
---
The first error looks like a bug.
The second one: I don't know if the template deduction engine is supposed to resolve this.
More information about the Digitalmars-d-learn
mailing list