www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - isCallable and templates

reply Steven Schveighoffer <schveiguy yahoo.com> writes:
Consider:

import std.traits;
class Foo
{
    void bar() {}
    void baz()() {}
}

This works:

static assert(isCallable!(Foo.bar));

This does not:

static assert(isCallable!(Foo.baz));

However, clearly I can call baz due to IFTI (with the equivalent syntax, 
someFoo.baz() or someFoo.baz). Is there a way to fix this?

-Steve
Jun 10 2016
parent ArturG <var.spool.mail700 gmail.com> writes:
On Friday, 10 June 2016 at 17:32:03 UTC, Steven Schveighoffer 
wrote:
 Consider:

 import std.traits;
 class Foo
 {
    void bar() {}
    void baz()() {}
 }

 This works:

 static assert(isCallable!(Foo.bar));

 This does not:

 static assert(isCallable!(Foo.baz));

 However, clearly I can call baz due to IFTI (with the 
 equivalent syntax, someFoo.baz() or someFoo.baz). Is there a 
 way to fix this?

 -Steve
i guess thats the same reason that isCallable!(unaryFun!someString) -> false if not, then it probably would also be usefull if it would be evaluated to true.
Jun 10 2016