digitalmars.D.learn - Arty of Constructor
- Andrew (4/4) Nov 18 2015 The documentation gives plenty of examples of how to use a static
- John Colvin (10/14) Nov 19 2015 Ugly but works:
The documentation gives plenty of examples of how to use a static if with the arity trait, but how do I specify the constructor of an object as the parameter to arity? Thanks
Nov 18 2015
On Thursday, 19 November 2015 at 06:20:28 UTC, Andrew wrote:The documentation gives plenty of examples of how to use a static if with the arity trait, but how do I specify the constructor of an object as the parameter to arity? ThanksUgly but works: import std.traits; struct A { this(int a, int b){} } pragma(msg, arity!(A.__ctor)); // prints 2 You may have to experiment with __traits(getOverloads, ...) if you have multiple constructors and want to look at all of them.
Nov 19 2015