Bug 435 – Constructors should be templatized

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2006-10-15T13:57:00Z
Last change time
2014-02-15T13:20:33Z
Keywords
pull
Assigned to
bugzilla
Creator
aarti

Attachments

IDFilenameSummaryContent-TypeSize
794constructor-template.patchPatch against dmd trunk r727, for D2text/plain1813
973contructor-template-modif.patchthis is a modification to initialize const membertext/plain2261

Comments

Comment #0 by aarti — 2006-10-15T13:57:16Z
It is not possible to make constructors as template functions. As constructor does not differ so much from function it should not be very difficult to implement it, but gives lot more flexibility.
Comment #1 by andrei — 2009-05-18T12:31:07Z
A quick unittest: class B { this(int) {} } class D : B { this(A...)(A args) { super(args); } } unittest { auto a = new D(4); }
Comment #2 by schveiguy — 2010-08-05T10:57:21Z
*** Issue 1462 has been marked as a duplicate of this issue. ***
Comment #3 by nfxjfg — 2010-09-21T04:59:11Z
*** Issue 4905 has been marked as a duplicate of this issue. ***
Comment #4 by rsinfu — 2010-10-25T11:39:57Z
Created attachment 794 Patch against dmd trunk r727, for D2 This is a D2 enhancement patch. Passed dmd/druntime/phobos tests and testcases in the reports. class.c: Just added isTemplateDeclaration() to an if condition. It makes the ClassDeclaration recognize constructor templates as its constructors. expression.c: Changed toParent() to isThis(). toParent() doesn't check through template instances and misunderstands that constructor is not declared inside a class or struct. isThis() (or toParent2) takes care of such cases.
Comment #5 by sweatygarlic — 2011-05-15T09:57:25Z
Created attachment 973 this is a modification to initialize const member this contains the diff of `794: Patch against dmd trunk r727, for D2'
Comment #6 by mathias.baumann — 2011-10-03T04:59:29Z
This fix seems to have not made it to dmd v1.071 Could D1 also be fixed, please? --Marenz
Comment #7 by kennytm — 2012-02-09T14:07:28Z
*** Issue 4531 has been marked as a duplicate of this issue. ***
Comment #8 by kennytm — 2012-02-09T14:42:55Z
Pull #703 (which is the same as patch 794 here). https://github.com/D-Programming-Language/dmd/pull/703
Comment #9 by github-bugzilla — 2012-02-18T23:48:03Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/18e6ecf0e3680fff13ac77f3a4d6de5a459a9ca6 Merge pull request #703 from kennytm/bug435_template_ctor Bug 435: Constructors should be templatized