__traits and std.traits and constructors

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 14 17:57:22 PST 2010

On Sunday 14 November 2010 07:13:43 Philippe Sigaud wrote:
> On Sun, Nov 14, 2010 at 11:16, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> > Is there a way to get use constructors with traits functions that take a
> > function? For instance, functionAttributes!(func) takes a func and tells
> > you whether it's pure, nothrow, etc. However, giving it the type doesn't
> > work (i.e. functionAttributes!T), and giving it this doesn't work (i.e.
> > functionAttributes! (T.this)), and functionAttributes!(T()) doesn't work
> > either (though that's probably trying to use opCall()). Is there a way
> > to pass the constructor to traits functinos like functionAttributes!().
> > And if so, how?
> does T.__ctor work?
> I mean, when you ask for the members with __traits(AllMembers, T),
> constructors are given as __ctor and have type: T delegate(args).
> So maybe the constructors are indeed internally called "__ctor".

That does indeed appear to do the trick. Thanks!

- Jonathan M Davis

More information about the Digitalmars-d-learn mailing list