Specialization Not Allowed for Deduced Parameter
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 22 21:41:43 PDT 2014
On 08/22/2014 07:47 PM, Yota wrote:
> So what's up with the syntax I tried before? Has it been
> deprecated?
I don't know the details. I am curious as well.
I think it is related to value template parameters. The first example
below fails but the second one works. The only difference is that the
one that fails uses a string value parameter like your original code did.
// This program FAILS
struct A(string S)
{}
void foo(T : A!S, string S)(T t) // <- string value
{}
void main()
{
auto a = A!"hello"();
foo(a);
}
// This program WORKS
struct A(S)
{}
void foo(T : A!S, S : int)(T t) // <- int parameter
{}
void main()
{
auto a = A!int();
foo(a);
}
So, I don't know whether it should work but at least the previous
programs show that it is indeed possible to specialize using a "deduced
parameter" (i.e. S being 'int' in the program that works).
Ali
More information about the Digitalmars-d-learn
mailing list