[Issue 493] New: Partial IFTI does not work
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 9 20:21:40 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=493
Summary: Partial IFTI does not work
Product: D
Version: 0.173
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: wbaxter at gmail.com
IFTI should try to deduce the parameter types for any template paramters not
specified (if they don't have defaults).
--------
import std.stdio:writefln;
template foo(T,S)
{
void foo(T t, S s) {
writefln("typeof(T)=",typeid(typeof(T)),"
typeof(S)=",typeid(typeof(S)));
}
}
template bar(T,S)
{
void bar(S s) {
writefln("typeof(T)=",typeid(typeof(T)),"
typeof(S)=",typeid(typeof(S)));
}
}
void main()
{
// OK -- IFTI works happily
foo(1.0,33);
// OK -- Full template parameters specified
bar!(double,int)(33);
// error: I gave it T and it should be able to use IFTI to guess S, but it
doesn't
//bar!(float)(33);
}
---------------
Not sure if this should be a bug or an enhancement, but anyway, especially with
the new variadic templates I think it will become more common to want to have a
few specified paramters and let IFTI guess the rest.
templatefunc(T, Var...)(Var v) {
[...]
}
templatefunc!(SomeType)(a,b,c,d,e);
This basically isn't usable if I have to specify all the types for a,b,c,
and d.
--
More information about the Digitalmars-d-bugs
mailing list