Checked casts in CNI
Tom Tromey
tromey@redhat.com
Mon Jun 6 20:30:00 GMT 2005
>>>>> "Bryce" == Bryce McKinlay <mckinlay@redhat.com> writes:
Bryce> I think this is a good idea, although it would be even nicer if we
Bryce> could make it use the C++-style casting syntax. For example:
Bryce> addr = java_cast<::java::net::InetAddress> (value);
I've considered in the past using 'dynamic_cast<>' for this, but I
wonder whether the g++ maintainers would accept that.
Yours is easy though :-). (Though I didn't actually test it or anything)
template<typename T, typename S>
inline T
java_cast (S value)
{
return reinterpret_cast<T *> (_Jv_CheckCast (&T::class,ドル value));
}
This is a little peculiar since the template type argument is the
class and not a pointer to the class.
Tom
More information about the Java
mailing list