digitalmars.D - cleaner approach of variadic arg deduce, inspired by Jarrett Billingsley
- Davidl (47/47) Apr 01 2007 the following is trying to deduce the variadic call to a chain of functi...
the following is trying to deduce the variadic call to a chain of functi= on = call. the problem is only appeard on current DMD when deduce the last paramete= r = 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~=3D format(`int`,x); } /* this(float x, A a...) { }*/ this(int x) { output~=3D format(`int`,x); } this(float x) { output~=3D format(`float`,x); } } void func(A a...) { foreach_reverse(k;a.output) { writef(k); } a.output.length =3D 0; } void main() { func(1,4,2.0); func(1,5,2.0); }
Apr 01 2007