Check the class of objects
Mael
mael.primet at gmail.com
Thu Jun 5 09:23:34 PDT 2008
Well, most of the time, the check won't occur a big penalty, because, first the image hierarchy will be small, and second, the pattern of use will be like :
algorithmprocess(Type)(args)
{
static switch(Type) dostuff ;
}
algorithm(args)
{
if( isByteImage(img) ) algorithmprocess(ByteImage)(cast(ByteImage)img) ;
...
}
which is a bit ugly but should work.. except I can't make it work :
I did something like
_myalgo( T )( T u )
{
static if (T == ByteImage) { do something ; }
else static if( T == FloatImage) { ..; }
}
myalgo( Image u )
{
if( isByteImage(u) ) _myalgo( ByteImage )(cast(ByteImage)u) ;
...
}
and I obtain something like
Error: cannot evaluate opEquals(cast(Object)(ByteImage)) at compile time
(refering to the line "static if( T == ByteImage ) .."
someone knows what is the correct way to check for the arg types?
sorry to ask newb question ..
More information about the Digitalmars-d-learn
mailing list