On Monday, 18 November 2013 at 19:12:03 UTC, Ali Çehreli wrote:
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
I was more looking for a way to just access a type/class by
specifying an index... I don't really get your code.