[Issue 1997] New: Better type inference for templated types
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 15 17:36:25 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1997
Summary: Better type inference for templated types
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: simen.kjaras at gmail.com
In the following code, a shortcoming of current type inference is pointed out:
struct foo(T)
{
T data;
static foo!(T) opCall(T t)
{
foo!(T) result;
result.data = t;
return result;
}
}
auto f = foo(4);
The line with 'f = foo(4)' gives a template instantiation error, while it
should be possible for the compiler to infer the template parameters from the
call.
auto g = foo!(int)(4);
This works, but is nowhere near as pretty.
--
More information about the Digitalmars-d-bugs
mailing list