Solution to "statement is not reachable" depending on template variables?
Moritz Maxeiner via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 18 06:48:52 PDT 2017
On Sunday, 18 June 2017 at 11:11:59 UTC, Johan Engelen wrote:
> On Sunday, 18 June 2017 at 09:56:50 UTC, Steven Schveighoffer
> wrote:
>> On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote:
>>> Reviving this thread to see whether anything has changed on
>>> the topic.
>>>
>>
>> If Timon gets static for each into the language, it can look a
>> little better.
>
> Can you help me understand what you mean? How will it improve
> things? (static foreach would disable the "statement not
> reachable" analysis?)
The new static foreach is AFAIK supposed to execute the loop
instead of unrolling it, i.e. the expansion of
---
foreach (i, U; T) {
static if (is(U == bool)) {
return false;
}
}
return true;
---
to
---
static if (is(U1 == bool)) {
return false;
}
static if (is(U2 == bool)) {
return false;
}
...
return true;
---
, which triggers that "statement is not reachable" if at least
one of U1,U2,... = T is bool, will not occur if you instead use
`static foreach (i, U; T)`.
More information about the Digitalmars-d-learn
mailing list