Bug 15719 – Can't make template with name "this"

Status
RESOLVED
Resolution
WONTFIX
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2016-02-24T11:12:17Z
Last change time
2022-11-03T10:04:16Z
Assigned to
No Owner
Creator
Lass Safin

Comments

Comment #0 by lasssafin — 2016-02-24T11:12:17Z
You can't have a template inside an aggregate with the name "this". This prevents one from creating an advanced function template. This works: struct S { this(int i)(float f) {} } This doesn't: struct S { template this(int i) { this(float f) {} } }
Comment #1 by nick — 2022-09-14T13:23:25Z
Technically, the 2nd form is not a function template because there's no identifier. The first example is a constructor template. Do you have a compelling reason why the 2nd form should be supported?