Bug 1462 – Templated constructor not supported

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2007-08-31T09:33:00Z
Last change time
2015-06-09T01:14:15Z
Keywords
spec
Assigned to
nobody
Creator
reiner.pope

Comments

Comment #0 by reiner.pope — 2007-08-31T09:33:31Z
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 ***