Get constructor for a class

simendsjo simendsjo at gmail.com
Fri Sep 13 06:31:33 PDT 2013


On Friday, 13 September 2013 at 13:16:12 UTC, Gary Willoughby 
wrote:
> On Friday, 13 September 2013 at 09:12:53 UTC, simendsjo wrote:
>> allMembers returns "this", but trying to get "this" or 
>> "__ctor" using getMember fails. Is there any way to get this 
>> method?
>
> foreach (func; __traits(getOverloads, T, "__ctor"))
> {
> 	...
> }

Thanks.

Still a bit strange though.. "this" is always a member for 
classes, but if there's only an implicit ctor, only "this" 
exists, and getOverloads "__ctor" fails.

If there exists explicit ctors on the other hand, both "this" 
*and* "__ctor" exists.


More information about the Digitalmars-d-learn mailing list