On Tuesday, 26 May 2015 at 06:04:59 UTC, Tofu Ninja wrote:
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, ...)?
Apparently yes, which surprised me. Storage classes and
TypeTuples (or Arguments, as they are now) are a bit of a dark
corner. E.g.
void foo(ref int, ref int);
alias A(T...) = T;
static assert(is(ParameterTypeTuple!foo ==
A!(ParameterTypeTuple!foo)));
That fails.