I need to generate some meta info of my data types. I do it this [way](https://gist.github.com/drug007/b0a00dada6c6ecbf46b4f6988401d4e2):
```D
import std.range, std.format, std.stdio, std.traits;

struct NestedType
{
    string s;
    double d;
}

struct Node
{
    string value;
    int i;
    NestedType nt;
    // Node[] children; // It makes Node to be a recursive data types
}

template Meta(A)
{
    static if (isRandomAccessRange!A)
        alias Meta = RaRMeta!A;
    else static if (isSomeString!A || isIntegral!A || isFloatingPoint!A)
        alias Meta = ScalarMeta!A;
    else
        alias Meta = AggregateMeta!A;
}

struct RaRMeta(A)
{
    alias ElementType = typeof(A.init[0]);
    Meta!ElementType[] model;
}

struct ScalarMeta(A) {}

struct AggregateMeta(A)
{
    static foreach (member; __traits(allMembers, A))
        mixin("Meta!(typeof(A.%1$s)) %1$s;".format(member));
}

void main()
{
    auto meta = Meta!Node();

    assert(meta.value == ScalarMeta!string());
    assert(meta.i == ScalarMeta!int());
    assert(meta.nt == AggregateMeta!NestedType());

    assert(meta.nt.s == ScalarMeta!string());
    assert(meta.nt.d == ScalarMeta!double());
}
```
It works. But when I try to wrap around a recursive data type (uncomment `children` member of `Node` type) it fails because during instantiating of `Meta!Node` it needs complete `Meta!Node` type to process `children` member of `Node`.

How can I "break" this recursion or some other work around to fix it?

Reply via email to