D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15719 - Can't make template with name "this"
Summary: Can't make template with name "this"
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P1 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-24 11:12 UTC by Lass Safin
Modified: 2022-11-03 10:04 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lass Safin 2016-02-24 11:12:17 UTC
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 Nick Treleaven 2022-09-14 13:23:25 UTC
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?