trunk/src/emu/emucore.h
| r20630 | r20631 | |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | |
| 384 | | // template function for cross-casting from one class to another that throws a bad_cast |
| 385 | | // exception instead of returning NULL |
| 386 | | template<class _Dest, class _Source> |
| 387 | | inline _Dest crosscast(_Source *src) |
| 388 | | { |
| 389 | | _Dest result; |
| 390 | | #ifdef MAME_DEBUG |
| 391 | | try |
| 392 | | { |
| 393 | | #endif |
| 394 | | result = dynamic_cast<_Dest>(src); |
| 395 | | #ifdef MAME_DEBUG |
| 396 | | } |
| 397 | | catch (std::bad_cast &) |
| 398 | | { |
| 399 | | report_bad_cast(typeid(src), typeid(_Dest)); |
| 400 | | } |
| 401 | | #endif |
| 402 | | assert(result != NULL); |
| 403 | | if (result == NULL) |
| 404 | | throw std::bad_cast(); |
| 405 | | return result; |
| 406 | | } |
| 407 | 384 | |
| 408 | | |
| 409 | | |
| 410 | 385 | //************************************************************************** |
| 411 | 386 | // FUNCTION PROTOTYPES |
| 412 | 387 | //************************************************************************** |