Enum type deduction inside templates is not working

pgtkda via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 26 23:42:58 PDT 2014


On Friday, 27 June 2014 at 06:21:11 UTC, Uranuz wrote:
> On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote:
>> On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote:
>> How I could make this
>>>> working without explicit specifying of types?
>>
>> sorry, i should read better
>
> Ok. Maybe it was discussed already somewhere, but I am not god 
> in searching in English. Is there any directions about it? How 
> could I work around it? Should I mail some proposal or bug 
> report for it?

I think, D is a typesafe language, therefore you can't use 
variables with no type declaration.

One thing you can search for, are templates but even there you 
have to define a type:

import std.stdio;

enum Category : string { first = "first"}

template Pair(T)
{
	T t;
	T cat;
}


void main()
{
	alias Pair!(string) a;
	a.cat = Category.first;
	a.t = "first";

	writeln(a.cat, " . ", a.t);
}


More information about the Digitalmars-d-learn mailing list