Lazy variadic not working, any alternatives?

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 25 23:04:57 PDT 2015


On Tuesday, 26 May 2015 at 05:54:11 UTC, John Colvin wrote:
> Something like this appears to work:
>
> import std.typetuple : allSatisfy;
>
> enum implicityConvertibleToBool(T) = is(T : bool);
>
> bool tok_and(Args...)(lazy Args terms)
> if(allSatisfy!(implicitlyConvertibleToBool, Args))
> {
> 	auto backup = getInputLocation();
> 	foreach(term; terms)
> 	{
> 		if(term == false)
> 		{
> 			rewind(backup);
> 			return false;
> 		}
> 	}
> 	return true;
> }

Hmmm.... this does seem to work. Does this essentially expand out 
to tok_and(lazy bool arg1, lazy bool arg2, ...)?


More information about the Digitalmars-d-learn mailing list