Generality creep
Kagamin
spam at here.lot
Thu Mar 21 18:34:38 UTC 2019
On Thursday, 21 March 2019 at 16:11:04 UTC, Joseph Rushton
Wakeling wrote:
> @property bool empty (T) (auto ref scope T a)
> if(is(ReturnType!((T t) => t.length) : size_t))
> {
> return !a.length;
> }
Here comes generality creep :)
struct A
{
int a;
@disable this(this);
bool opCast(){ return !!a; }
}
struct S
{
A a;
ref A p() { return a; }
}
T property(T)(auto ref T a);
import std.traits;
void f()
{
S s;
assert(!s.p); //negation works
static assert(is(typeof(property(s.p))==A));
static assert(is(ReturnType!(()=>s.p):A));
}
The ReturnType assert doesn't pass. Any idea why? Well, maybe it
shouldn't.
More information about the Digitalmars-d
mailing list