On 8/18/21 4:10 AM, Rekel wrote:

>>   isArray!T && (isArray!(ElementType!T))
>
> I tried looking into how isArray is defined. Like, does being able to
> index mean it's an array, or are these only static &/or dynamic arrays?

The definitions are in phobos/std/traits.d

  enum bool isArray(T) = isStaticArray!T || isDynamicArray!T;

isStaticArray uses the compiler's __traits feature:

  enum bool isStaticArray(T) = __traits(isStaticArray, T);

isDynamicArray uses the is expression but apparently has some history:

template isDynamicArray(T)
{
    static if (is(T == U[], U))
        enum bool isDynamicArray = true;
    else static if (is(T U == enum))
        // BUG: isDynamicArray / isStaticArray considers enums
        // with appropriate base types as dynamic/static arrays
        // Retain old behaviour for now, see
        // https://github.com/dlang/phobos/pull/7574
        enum bool isDynamicArray = isDynamicArray!U;
    else
        enum bool isDynamicArray = false;
}

Ali

Reply via email to