Class template argument deduction from constructor call
div0
div0 at sourceforge.net
Wed Oct 27 12:48:35 PDT 2010
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.
--
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
More information about the Digitalmars-d-learn
mailing list