[Issue 6082] New: Constructors of templated types should be callable vi IFTI
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 31 12:41:10 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6082
Summary: Constructors of templated types should be callable vi
IFTI
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: schveiguy at yahoo.com
--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-05-31 12:36:46 PDT ---
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list