Yeah, that's what you get when you press the wrong buttons. :p
Anyways, Rebindable should be castable to bool, to allow for the idiom Rebindable!T foo; if (foo) {}.
Addition to typecons.d, line 747:
T opCast(T : bool)()
{
return original !is null;
}
Comment #2 by rsinfu — 2010-10-08T13:18:00Z
Actually, it's explicitly castable to bool:
Rebindable!(const Object) r;
if (cast(bool) r) assert(0);
r = new Object;
if (!cast(bool) r) assert(0);
But dmd doesn't forward implicit boolean conversions in if (or other) conditions to Rebindable's alias-this object. Reported: bug 5020.
Comment #3 by k.hara.pg — 2011-07-26T21:07:23Z
This is dmd issue.
Fixing bug5020 is incomplete, so property function + alias this is not implicitly convertible to bool.
----
struct Rebindable
{
Object obj;
@property const(Object) get(){ return obj; }
alias get this;
}
Rebindable r;
if (r) assert(0);
r.obj = new Object;
if (!r) assert(0);
----