Traits

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 11 12:54:29 PDT 2013


On Friday, October 11, 2013 21:19:29 luminousone wrote:
> Using casts that way won't always be correct, it would be better
> to use reflection in some way if possible.

The only reason that the casts wouldn't be correct would be if the class 
overrode opCast for the type that you're casting to or had an alias this 
declaration for it. Using casting for "instanceOf" is considered the standard 
and correct way to do it. But if you're being paranoid about the possibility 
of a conversion being defined with opCast or alias this, then yes, you need to 
use typeid.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list