Lazy variadic not working, any alternatives?
Tofu Ninja via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 25 22:43:57 PDT 2015
On Tuesday, 26 May 2015 at 05:22:26 UTC, Tofu Ninja wrote:
Actually the code seems to compile on 2.067.1 but definitely does
not work as expected.
Another example of Lazy variadic to show how it works...
void main(string[] args)
{
test(a(), b(), c());
}
bool a()
{
writeln("a");
return true;
}
bool b()
{
writeln("b");
return true;
}
bool c()
{
writeln("c");
return true;
}
void test(lazy bool[] c...)
{
for(int i = 0; i < c.length; i++)
{
writeln("iteration: ", i);
if(c[i]) writeln("success");
}
}
prints...
a
b
c
iteration: 0
a
b
c
success
a
b
c
iteration: 1
a
b
c
success
a
b
c
iteration: 2
a
b
c
success
a
b
c
Though because it still runs in order, maybe I can still make
this work...
More information about the Digitalmars-d-learn
mailing list