On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended"
solution for the problem of "statement is not reachable"
warnings in templates with early returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
static if (is(U == bool)) {
return false;
}
}
return true; // emits "Warning: statement is not reachable"
}
[...]
On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen 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.