On 2011/09/23 1:11, Benjamin Thaut wrote:
Is there a way to get a type tuple of all aviable constructors in a class?

class Test {
public:
this(Foo foo){
m_foo = foo;
}

this(bool flop){
}

this(int x, int y){
}
}

For this class I would expect something like ((Foo),(bool),(int,int))

$ cat test.d
struct Foo {}

class Test {
  public:
    this(Foo foo){
    }

    this(bool flop){
    }

    this(int x, int y){
    }
}

import std.traits;
import std.stdio;

void main()
{
        foreach(ctor; __traits(getOverloads, Test, "__ctor"))
        {
                alias ParameterTypeTuple!(typeof(ctor)) args;
                writeln(args.stringof);
        }
}

$ ./test
(Foo)
(bool)
(int, int)

Reply via email to