Runtime class check
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Fri Apr 20 14:33:59 PDT 2007
funog wrote:
> BCS Wrote:
>
>> funog wrote:
>>> Is there a way to have a runtime class check other than
>>> if(cast(X)y)
>>> ( It just does not look really "nice" to me ^^)
>>>
>> Unless you are not going to use it as the type you are checking for
>> what's wrong with that (or this)
>>
>> if(auto x = cast(X) y)
>> {
>> // use x
>> }
>
> You are right, it's nice. But i guess it means the answer to my question is "no" ;)
Not strictly speaking, but certainly nothing more elegant. You could presumably, for
example, compare the .classinfo referances -- if (y.classinfo is X.classinfo) -- but...
ew. :)
-- Chris Nicholson-Sauls
More information about the Digitalmars-d-learn
mailing list