class MyClass
{
T opCall(T)(T p) { return p; }
}
void emplaceRef(T, Args...)(ref T chunk, auto ref Args args)
{
static assert(!__traits(compiles, chunk = T(args)));
// the following fails: `!is(MyClass)` is false
static assert(!is(typeof(chunk = T(args))));
}
int foo()
{
MyClass c;
emplaceRef(c, new MyClass);
}
Comment #1 by boris2.9 — 2021-01-18T02:34:30Z
Is not this intended? typeof doesn't evaluate the expression.
I remember seeing phobos depending on this exact behavior.
class A { int fun(); }
static assert(is(typeof(A.fun()) == int));
static assert(!__traits(compiles, A.fun())); // Error: need this for fun of type int()