Check for presence of function
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sun Mar 23 06:50:47 PDT 2014
On 3/23/14, Philippe Sigaud <philippe.sigaud at gmail.com> wrote:
> But this is not accepted by the grammar right now, because of __traits()
Pretty sure it's because you're using 'alias' instead of 'enum'. This works:
-----
enum isSomething(T) = __traits(compiles,
{
int up;
T.init.doSomething(up);
}
);
void main()
{
static struct S { void doSomething(int); }
static struct X { void doSomething(string); }
static assert(isSomething!S);
static assert(!isSomething!X);
}
-----
More information about the Digitalmars-d-learn
mailing list