Changeset 7284 for code/trunk/src/libraries/util/Convert.h
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/Convert.h
r7266 r7284 109 109 } 110 110 }; 111 112 //////////// 113 // upcast // 114 //////////// 115 namespace detail 116 { 117 // perform a static cast if ToType is a base of FromType 118 template<class ToType, class FromType> 119 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<true>) 120 { 121 return static_cast<ToType>(input); 122 } 123 124 // return zero if ToType is not a base of FromType 125 template<class ToType, class FromType> 126 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<false>) 127 { 128 return 0; 129 } 130 } 131 132 // performs an upcast if ToType is a base of FromType, returns zero otherwise 133 template <class ToType, class FromType> 134 FORCEINLINE ToType upcast(FromType input) 135 { 136 enum { probe = ImplicitConversion<FromType, ToType>::exists }; 137 return detail::upcast<ToType, FromType>(input, Loki::Int2Type<probe>()); 138 } 111 139 } 112 140
Note: See TracChangeset
for help on using the changeset viewer.