isInnerClass

Determines whether T is a class nested inside another class and that T.outer is the implicit reference to the outer class (i.e. outer has not been used as a field or method name)

template isInnerClass (
T
) if (
is(T == class)
) {
static if(is(typeof(T.outer)))
enum isInnerClass;
static if(!(is(typeof(T.outer))))
enum isInnerClass;
}

Parameters

T

type to test

Return Value

true if T is a class nested inside another, with the conditions described above; false otherwise

Examples

class C
{
    int outer;
}
static assert(!isInnerClass!C);

class Outer1
{
    class Inner1 { }
    class Inner2
    {
        int outer;
    }
}
static assert(isInnerClass!(Outer1.Inner1));
static assert(!isInnerClass!(Outer1.Inner2));

static class Outer2
{
    static class Inner
    {
        int outer;
    }
}
static assert(!isInnerClass!(Outer2.Inner));

Meta