Bug 6082 – Constructors of templated types should be callable via IFTI

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-05-31T12:36:46Z
Last change time
2024-12-13T17:55:21Z
Keywords
pull
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: dmd#18343 →

Comments

Comment #0 by schveiguy — 2011-05-31T12:36:46Z
If I have the following class: class A(T) { this(T t) {} } I must specify the class type in order to call its constructor: auto a = new A(1); // error auto b = new A!int(1); // ok But IFTI works in this instance: template foo(T) { void foo(T t) {} } I see little difference between the first and second cases -- both must be partially instantiated by the compiler to determine if there is a valid function to call. Further supporting this, I can add a factory function: A(T) createA(T)(T t) { return new A!T(t); } which now is callable via IFTI: auto a = createA(1); // ok. It seems like the necessary logic is present in the compiler, it just needs to be utilized during a constructor call. The same should apply to structs.
Comment #1 by schveiguy — 2013-05-13T15:54:21Z
Comment #2 by jakobovrum — 2014-07-24T05:47:40Z
*** Issue 13196 has been marked as a duplicate of this issue. ***
Comment #3 by b2.temp — 2016-09-11T13:31:03Z
*** Issue 16465 has been marked as a duplicate of this issue. ***
Comment #4 by schveiguy — 2018-03-02T13:58:19Z
*** Issue 18546 has been marked as a duplicate of this issue. ***
Comment #5 by dlang-bot — 2024-10-02T15:31:02Z
@dkorpel created dlang/dmd pull request #16910 "[WIP] Fix bugzilla 6082 - Constructors of templated types should be callabl…" fixing this issue: - Fix bugzilla 6082 - Constructors of templated types should be callable via IFTI https://github.com/dlang/dmd/pull/16910
Comment #6 by robert.schadek — 2024-12-13T17:55:21Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18343 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB