On Friday, 9 March 2018 at 22:13:39 UTC, Simen Kjærås wrote:
static if (allEqual!(staticMap!(ElementEncodingType, Rs)))
{
    // compare Rs byCodeUnit
}

NoDuplicates!V.length == 1

BTW, `NoDuplicates` can handle both types and values (mixed) opposite to my `allSame` and `allSameType` defined as:

template allSame(V...)
    if (isExpressions!V)
{
    static if (V.length <= 1)
    {
        enum allSame = true;
    }
    else static if (V.length & 1) // odd count
    {
        enum allSame = (V[0] == V[$ - 1] && // first equals last
V[0 .. $/2] == V[$/2 .. $-1] && // (first half) equals (second half minus last element)
                        allSame!(V[0 .. $/2]));
    }
    else                        // event count
    {
enum allSame = (V[0 .. $/2] == V[$/2 .. $] && // (first half) equals (second half)
                        allSame!(V[0 .. $/2]));
    }
}

and

template allSameType(V...)
    // TODO should have template restriction on `V`
{
    static if (V.length <= 1)
    {
        enum allSameType = true;
    }
    else static if (V.length & 1) // odd count
    {
enum allSameType = (is(V[0] == V[$ - 1]) && // first equals last is(V[0 .. $/2] == V[$/2 .. $-1]) && // (first half) equals (second half minus last element)
                            allSameType!(V[0 .. $/2]));
    }
    else                        // even count
    {
enum allSameType = (is(V[0 .. $/2] == V[$/2 .. $]) && // (first half) equals (second half)
                            allSameType!(V[0 .. $/2]));
    }
}

How do I most conveniently merge these into one single `allSame` that can operate on mixtures of values and types?

Reply via email to