div0 wrote: > On 27/10/2010 20:36, sergk wrote: >> class Foo(T) { >> this(T t) { >> bar = t; >> } >> T bar; >> } >> >> void main() { >> auto a = new Foo(123); // doesn't work >> auto b = new Foo!(int)(123); // work, but redundant >> } >> >> Is there any technical limitations preventing this, or its just a >> compiler bug? > > It's not a bug. > > I guess it could be a short cut, but it can only ever work when the > class has exactly one constructor, which seems a bit of a pointless > short cut and adds an unneccassiry corner case to the language spec. > Why would it only be able to work when there is exactly one constructor? Doesn't function overloading work with templates?
This works here: void foo(T) (T x) { } void foo(T, U) (T x, U y) { } void main() { foo (3); foo (3, "azerty"); } Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr
signature.asc
Description: OpenPGP digital signature