On 1/29/16 10:28 AM, Adrian Matoga wrote:
Code:

----
struct HasFoo { void foo() {} }

struct NoFoo {}

struct CallsFoo(T) {
     T t;
     void bar() { t.foo(); }
}

static assert(is(CallsFoo!HasFoo));
alias Bar = CallsFoo!HasFoo;

static assert(is(CallsFoo!NoFoo)); // (1)
//alias Baz = CallsFoo!NoFoo;      // (2)
----

This compiles, although I expected that (1) should fail.
Now try uncommenting (2) and it can't be compiled.

Why does `is(CallsFoo!NoFoo)` evaluate to true if `is(CallsFoo!NoFoo)`
can't be instantiated?
Am I missing something about `is(T)` or is it a bug?
How can I reliably test if CallsFoo can be instantiated?


is(T) is supposed to be false if T is not a valid type.

I would agree with you that the static assert should fail.

-Steve

Reply via email to