Changeset 3239 for code/branches/core4/src/core/Identifier.h
- Timestamp:
- Jun 28, 2009, 2:45:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/Identifier.h
r3224 r3239 483 483 // ### orxonox_cast ### 484 484 // ############################### 485 //! Helper struct to have orxonox_cast<T*> instead of orxonox_cast<T> 486 template <class T, class U> 487 struct OrxonoxCaster 488 { 489 static T* cast(U* source) 490 { 491 // If you see this function in a compiler error description, it means 492 // you were misusing orxonox_cast. You must always cast to a pointer type! 493 *****T(); 494 } 495 }; 496 497 //! Helper struct to have orxonox_cast<T*> instead of orxonox_cast<T*> 498 template <class T, class U> 499 struct OrxonoxCaster<T*, U> 500 { 501 FORCEINLINE static T* cast(U* source) 502 { 503 #ifdef ORXONOX_COMPILER_MSVC 504 return source->template getDerivedPointer<T>(ClassIdentifier<T>::getIdentifier()->getClassID()); 505 #else 506 return dynamic_cast<T*>(source); 507 #endif 508 } 509 }; 510 485 511 /** 486 512 @brief … … 495 521 */ 496 522 template <class T, class U> 497 FORCEINLINE T* orxonox_cast(U* source) 498 { 499 #ifdef ORXONOX_COMPILER_MSVC 500 return source->template getDerivedPointer<T>(ClassIdentifier<T>::getIdentifier()->getClassID()); 501 #else 502 return dynamic_cast<T*>(source); 503 #endif 523 FORCEINLINE T orxonox_cast(U* source) 524 { 525 return OrxonoxCaster<T, U>::cast(source); 504 526 } 505 527 … … 597 619 if (newObject) 598 620 { 599 return orxonox_cast<T >(newObject);621 return orxonox_cast<T*>(newObject); 600 622 } 601 623 else
Note: See TracChangeset
for help on using the changeset viewer.