Changeset 7179 for code/branches/consolecommands3/src/libraries/util
- Timestamp:
- Aug 18, 2010, 3:39:01 PM (14 years ago)
- Location:
- code/branches/consolecommands3
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3
- Property svn:mergeinfo changed
/code/branches/consolecommands2 (added) merged: 6451-6454
- Property svn:mergeinfo changed
-
code/branches/consolecommands3/src/libraries/util/Convert.h
r7163 r7179 116 116 } 117 117 }; 118 119 //////////// 120 // upcast // 121 //////////// 122 namespace detail 123 { 124 // perform a static cast if ToType is a base of FromType 125 template<class ToType, class FromType> 126 FORCEINLINE ToType upcast(FromType input, detail::Int2Type<true>) 127 { 128 return static_cast<ToType>(input); 129 } 130 131 // return zero if ToType is not a base of FromType 132 template<class ToType, class FromType> 133 FORCEINLINE ToType upcast(FromType input, detail::Int2Type<false>) 134 { 135 return 0; 136 } 137 } 138 139 // performs an upcast if ToType is a base of FromType, returns zero otherwise 140 template <class ToType, class FromType> 141 FORCEINLINE ToType upcast(FromType input) 142 { 143 enum { probe = ImplicitConversion<FromType, ToType>::exists }; 144 return detail::upcast<ToType, FromType>(input, detail::Int2Type<probe>()); 145 } 118 146 } 119 147
Note: See TracChangeset
for help on using the changeset viewer.