On 3/16/16 7:18 AM, 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" }
Instead of foreach, you could use recursive mechanism. Not ideal, but it would work.
Another possibility: foreach(i, U; T) { static if(is(U == bool)) { return false; } else static if(i + 1 == T.length) { return true; } } -Steve