digitalmars.D.bugs - [Issue 13196] New: Infer struct/class template args from constructor
- via Digitalmars-d-bugs (37/37) Jul 23 2014 https://issues.dlang.org/show_bug.cgi?id=13196
https://issues.dlang.org/show_bug.cgi?id=13196 Issue ID: 13196 Summary: Infer struct/class template args from constructor args Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: turkeyman gmail.com It would be really nice if struct/class template args could be inferred from their constructors, just the same as function template args are inferred from the runtime args. struct S(T) { this(T t) { m = t; } T m; } int myThing; auto s = S!(typeof(myThing))(myThing); // horrible! auto s = S(myThing); // this is much nicer, but not supported The error is: Error: struct db.tools.delegatethunk.S cannot deduce function from argument types !()(int), candidates are: db.tools.delegatethunk.S(T) It seems the compiler is already well aware there is only one possibly match. These sorts of issues pay off in meta-heavy code when used alongside non-template types. I find my meta often gets overwhelmed by additional meta to check for and handle edge cases like this. --
Jul 23 2014