Changeset 6452 for code/branches/consolecommands2/src/libraries/util
- Timestamp:
- Jan 20, 2010, 2:21:10 PM (15 years ago)
- Location:
- code/branches/consolecommands2/src/libraries/util
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands2/src/libraries/util/Convert.h
r6417 r6452 115 115 } 116 116 }; 117 118 //////////// 119 // upcast // 120 //////////// 121 namespace detail 122 { 123 // perform a static cast if ToType is a base of FromType 124 template<class ToType, class FromType> 125 FORCEINLINE ToType upcast(FromType input, detail::Int2Type<true>) 126 { 127 return static_cast<ToType>(input); 128 } 129 130 // return zero if ToType is not a base of FromType 131 template<class ToType, class FromType> 132 FORCEINLINE ToType upcast(FromType input, detail::Int2Type<false>) 133 { 134 return 0; 135 } 136 } 137 138 // performs an upcast if ToType is a base of FromType, returns zero otherwise 139 template <class ToType, class FromType> 140 FORCEINLINE ToType upcast(FromType input) 141 { 142 enum { probe = ImplicitConversion<FromType, ToType>::exists }; 143 return detail::upcast<ToType, FromType>(input, detail::Int2Type<probe>()); 144 } 117 145 } 118 146
Note: See TracChangeset
for help on using the changeset viewer.