Check the class of objects

Chris Wright dhasenan at gmail.com
Fri Jun 6 06:02:09 PDT 2008


Mael wrote:
>> What's wrong with:
>>
>> if(isByteImage(u))
>> { do something; }
>> ...
>>
>> Either way, you still need the if-else block to determine what the image is 
>> at runtime.
> 
> Well, actually the point is that the action "do something" is consistent accross images except when trying to access data (compare bytes/floats/value/triples), and using a run time if inside the loops would be unefficient, that's why I want to only use static if in the loop, but still share most of the code since it's truly redundant 

Why not use the Visitor pattern?


More information about the Digitalmars-d-learn mailing list