I know of no way to create a templated constructor for a class. (This is useful, for instance, with variadic template args). The following code fails to parse in compilation:
class Foo
{
this(T...)(T t) {}
}
Comment #1 by smjg — 2008-09-09T12:32:08Z
The problem seems to be that the current D syntax doesn't support it:
Constructor:
this Parameters FunctionBody
Parameters:
( ParameterList )
( )
The alternative would be
class Foo
{
template(T...) this {
this(T t) {}
}
}
except that this doesn't work because 'this' is a keyword, not an identifier.
Comment #2 by schveiguy — 2010-08-05T10:57:21Z
*** This issue has been marked as a duplicate of issue 435 ***