implicit constructor template instantiation

Daniel919 Daniel919 at web.de
Fri Nov 24 10:13:02 PST 2006


Hi,

this code is perfectly valid and working
with dmd 0.174:
------------------------------------------------
import std.stdio;

class Base
{
    this()
    {
       value = 0;
    }

    this(int a)
    {
       value = a;
    }

    int value;
}


class Derived (A...) : Base
{
    this(A a)
    {
       super(a);
    }
}

int main(char[][] args)
{
    Derived!(int) derived = new Derived!(int)(1);
    writefln(derived.value);
    return 0;
}
------------------------------------------------

But I would like to use implicit template
instantiation on constructor this as well.
So it would look like:

------------------------------------------------
...
class Derived : Base
{
    this(A...)(A a)
    {
       super(a);
    }
}
...
Derived derived = new Derived(1);
...
------------------------------------------------

Couldn't the constructor be implicitly templated, like
member function's, for example:
void print(A...)(A a) { } ?

Thanks for your replies in advance

Daniel



More information about the Digitalmars-d mailing list