cleaner approach of variadic arg deduce, inspired by Jarrett Billingsley
Davidl
Davidl at 126.com
Sun Apr 1 19:57:27 PDT 2007
the following is trying to deduce the variadic call to a chain of function
call.
the problem is only appeard on current DMD when deduce the last parameter
type double
it matches both
this(float y,A a...)
and
this(float y)
but actually it should just match this(float y) , and this would result
the correct
chain of calling.
import std.stdio;
import std.string;
class A
{
static char[][] output;
this(int x,A a...){
output~= format(`int`,x);
}
/* this(float x, A a...)
{
}*/
this(int x)
{
output~= format(`int`,x);
}
this(float x)
{
output~= format(`float`,x);
}
}
void func(A a...)
{
foreach_reverse(k;a.output)
{
writef(k);
}
a.output.length = 0;
}
void main()
{
func(1,4,2.0);
func(1,5,2.0);
}
More information about the Digitalmars-d
mailing list