On Friday, 27 June 2014 at 06:04:20 UTC, Uranuz wrote:
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?
is this a solution for your problem?
enum Category { first, second, third };
struct Pair
{
Category cat;
string second;
this(Category cat, string second){
this.cat = cat, this.second = second;
}
}
void main(){
auto p = Pair(Category.first, "first");
writeln(p);
}