[Issue 14835] Statement is not reachable doesn't play along generic code

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Oct 13 09:11:43 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14835

Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
Why can't the "hack" variable be eliminated by enclosing the rest of the
function in the else branch?

And what about this solution for the group comparison (copied from my post in
Issue 15166):

private bool compare(alias Group1, alias Group2)()
{
    foreach (index, element; Group!(Group1.expand, void).expand)
    {
        static if(index == Group1.expand.length)
            return true;
        else static if (!is(Group1.expand[index] == Group2.expand[index]))
            return false;
    }
}

Neither requires recursion.

--


More information about the Digitalmars-d-bugs mailing list