June 18, 2017 Re: Solution to "statement is not reachable" depending on template variables? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Johan Engelen | 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?)
>
> -Johan
On my phone so can't be too detailed, but you could do:
static foreach(i; 0..seq.length+1)
static if(seq.length == i)
return true;
else static if(is(seq[i] == bool))
return false;
Maybe looks a little better than the first workaround.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation