dummy question : runtime type testing...
Lloyd Dupont
ld-REMOVE at galador.net
Sat Jun 18 04:07:36 PDT 2011
on a related not.
in the (templated) function taking a variant, I use the coerce() method
which does some conversion (byte to int, for example)
the suggested code (while excellent, much thanks again!) is very stringent,
doesn't allow for such implicit conversion
i.e. with
bool isTypeOf(TypeInfo ti1, TypeInfo ti2) { return ( ti1 is ti2 ); }
isTypeOf(typeid(byte), typeid(int)) will return false.
is there (I might be pushing it here, I know :P) a way to make it return
true in such case??
"Mike Wey" wrote in message news:ithv61$2j5t$1 at digitalmars.com...
On 06/18/2011 05:28 AM, Lloyd Dupont wrote:
> ho... easy hey!
> but how about the other 2 test I'd like be able to run?
>
> bool isTypeOf(T)(TypeInfo ti) { "return T is ti" }
> bool isTypeOf(TypeInfo ti1, TypeInfo ti2) { "return ti1 is ti2" }
>
bool isTypeOf(T)(TypeInfo ti)
{
return ( typeid(T) is ti );
}
bool isTypeOf(TypeInfo ti1, TypeInfo ti2)
{
return ( ti1 is ti2 );
}
--
Mike Wey
More information about the Digitalmars-d-learn
mailing list