Check the class of objects
janderson
askme at me.com
Fri Jun 6 08:42:41 PDT 2008
Chris Wright wrote:
> 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?
This may be a good idea, however I wonder how you'd construct visitor
that does the right conversion since you can't have virtual template
inheritance. I guess you could write up a function for each version.
-Joel
More information about the Digitalmars-d-learn
mailing list