Enum type deduction inside templates is not working

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 26 23:04:18 PDT 2014


Compiler can't deduce type for template struct Pair when using it 
with enum argument.  There is an example

import std.stdio;

enum Category { first, second, third };

struct Pair(F, S)
{
	F first;
	S second;
	
	this(F f, S s)
	{
		first = f;
		second = s;
	}
}


void main()
{
	auto p = Pair(Category.first, "first"); //It fails
	
	writeln(p);
}

Is it not working for some reason or I'm doing something wrong or 
is it just lack of implementation? How I could make this working 
without explicit specifying of types?


More information about the Digitalmars-d-learn mailing list