Solution to "statement is not reachable" depending on template variables?

QAston via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 19 04:23:22 PDT 2016


On Wednesday, 16 March 2016 at 17:08:20 UTC, Johan Engelen wrote:
> On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote:
>> 
>> import std.meta;
>> template isBool(U)() = is(U == bool);
>> static if (!allSatisfy!(isBool, T)) {
>>     return true;  // no longer emits a warning
>> }
>>
>> Something like this should work.
>
> Thanks, but:
>
> On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen 
> wrote:
>> (I have heavily simplified the real-world code, please don't 
>> discuss alternative solutions to the "is(U==bool)" in 
>> particular. For sake of argument, assume that the predicate is 
>> a complicated beast.)

This method will work regarless of the predicate, just check if 
the predicate isn't matched for the whole array using 
allSatisfy/anySatisfy.


More information about the Digitalmars-d-learn mailing list