casting objects
BCS
BCS at pathlink.com
Thu Aug 17 15:31:27 PDT 2006
From http://www.digitalmars.com/d/expression.html#UnaryExpression
"Any casting of a class reference to a derived class reference is done
with a runtime check to make sure it really is a downcast."
it would be much more useful if this was:
"Any casting of a _reference_ to a class reference is done with a
runtime check to make sure it really is _valid_ cast."
This should be easy to do. Have some sort of static member for each
class the can recognize the vtbl pointer for any class that can be cast
to it. This would allow for things like this:
class foo {...}
void* vp;
...// set vp (maybe to a foo)
foo fig = cast(foo)vp;
if(null !is fig) writef("vp is a fig\n");
Thoughts? Comments?
More information about the Digitalmars-d-bugs
mailing list