On 11/18/2013 10:28 AM, Jeroen Bollen wrote:
Is it possible to do something like:

TestInterface testi = new classReferenceList[integer];

We still don't know what the use case is :) but it is possible to store types in a TypeTuple:

import std.stdio;
import std.typetuple;

interface I
{}

class C1 : I
{}

class C2 : I
{}

I makeObject(T)()
{
    return new T();
}

I[] makeObjects(Ts...)()
{
    I[] objects;

    foreach (T; Ts) {
        objects ~= makeObject!T();
    }

    return objects;
}

void main()
{
    alias typeList = TypeTuple!(C1, C2);

    auto objects = makeObjects!typeList();
    writeln(objects);
}

The output:

[deneme.C1, deneme.C2]

Ali

Reply via email to