digitalmars.D - Type tuple of all constructors?
- Benjamin Thaut <code benjamin-thaut.de> Sep 22 2011
- Jakob Ovrum <jakobovrum+ng gmail.com> Sep 22 2011
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))
--
Kind Regards
Benjamin Thaut
Sep 22 2011
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)
Sep 22 2011








Jakob Ovrum <jakobovrum+ng gmail.com>