Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Rob T
On Thursday, 24 January 2013 at 22:49:33 UTC, Andrej Mitrovic wrote: On 1/24/13, Philippe Sigaud wrote: IIRC, you can use __traits(getOverloads, mytype.__ctor) to get all constructor overloads. See: http://dlang.org/traits.html#getOverloads I used this in conjunction with __traits(getMember,

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Andrej Mitrovic
On 1/24/13, Philippe Sigaud wrote: > IIRC, you can use __traits(getOverloads, mytype.__ctor) to get all > constructor overloads. > See: > http://dlang.org/traits.html#getOverloads > > I used this in conjunction with __traits(getMember, ...) to get the > entire list of member, overloads included. >

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Philippe Sigaud
On Thu, Jan 24, 2013 at 10:34 PM, Rob T wrote: > On Thursday, 24 January 2013 at 18:41:31 UTC, mist wrote: >> >> You can use "magic" functions __ctor and __dtor which actually serve as >> constructor and destructor implementations behind the scene. >> >> Example and proof-of-concept: http://dpaste

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Rob T
On Thursday, 24 January 2013 at 18:41:31 UTC, mist wrote: You can use "magic" functions __ctor and __dtor which actually serve as constructor and destructor implementations behind the scene. Example and proof-of-concept: http://dpaste.1azy.net/fd924332 Have no idea if it is explicitly defined

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread mist
You can use "magic" functions __ctor and __dtor which actually serve as constructor and destructor implementations behind the scene. Example and proof-of-concept: http://dpaste.1azy.net/fd924332 Have no idea if it is explicitly defined by spec somewhere though.

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Rob T
There may be more than one "this", so you'll have to specify the args for each specific constructor manually. Disclaimer: Someone else may have a better solution as I'm not that much of an expert in this area. This sample may point you in the right direction ... import std.typetuple; struct

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Joseph Rushton Wakeling
On 01/24/2013 06:14 PM, Andrej Mitrovic wrote: On 1/24/13, Joseph Rushton Wakeling wrote: ParameterTypeTuple!(A.this) Use ParameterTypeTuple!(A.__ctor) Brilliant. Thanks very much. :-)

Re: Getting the parameters of a struct/class constructor

2013-01-24 Thread Andrej Mitrovic
On 1/24/13, Andrej Mitrovic wrote: > On 1/24/13, Joseph Rushton Wakeling wrote: >> ParameterTypeTuple!(A.this) > > Use ParameterTypeTuple!(A.__ctor) > If you have multiple constructors you can pick the parameters with a helper template: import std.traits, std.string; struct A { th

Getting the parameters of a struct/class constructor

2013-01-24 Thread Joseph Rushton Wakeling
Hello all, Is there a way to construct a tuple of the types that need to be passed to a struct or class's constructor? I tried using ParameterTypeTuple either on the class or its constructor: ParameterTypeTuple!A or ParameterTypeTuple!(A.this) ... but neither works: the former gene