Class template argument deduction from constructor call
Steven Schveighoffer
schveiguy at yahoo.com
Wed Oct 27 19:13:52 PDT 2010
On Wed, 27 Oct 2010 22:10:24 -0400, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> To answer the OP's question, I don't think there's anything technical
> restricting the compiler from doing this. I believe it's been proposed
> several times. If you want to, you can work around the issue by making
> a wrapper constructor function:
>
> Foo!T makeFoo(T)(T t)
> {
> return new Foo!T(t);
> }
I should add, it would be ambiguous to do something like this:
class Foo(T, U)
{
this(T t, U u) {}
this(U u, T t) {}
}
This kind of situation currently doesn't exist in IFTI, since only
templates that have exactly one member and it is a function can
participate in IFTI.
But if the classes are made to work in normal cases, then I think IFTI can
be extended to support this kind of thing
-Steve
More information about the Digitalmars-d-learn
mailing list