Changeset 211
- Timestamp:
- 09/09/13 19:27:27 (12 years ago)
- Location:
- trunk/nv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/lua/lua_values.hh
r208 r211 52 52 namespace detail 53 53 { 54 struct void_type {}; 55 54 56 void push_unsigned( lua_State *L, lunsigned v ); 55 57 void push_integer ( lua_State *L, linteger v ); … … 238 240 239 241 template < typename T > 240 inline Tget_value( lua_State *L, int index )242 inline typename std::remove_reference<T>::type get_value( lua_State *L, int index ) 241 243 { 242 244 typedef typename type_degrade<T>::type degraded; -
trunk/nv/type_traits.hh
r208 r211 9 9 * @brief type traits 10 10 */ 11 // TODO: function_traits support only up to 4 parameters because: 12 // -- if you have more than 4 params, you're doing something wrong 13 // -- once the Variadic Templates cometh, for great justice we will win! 11 14 12 15 #ifndef NV_TYPE_TRAITS_HH … … 30 33 struct is_stdstring 31 34 : public std::integral_constant<bool, 32 std::is_same< std::string, typename std:: remove_cv< std::remove_reference< T >>::type >::value35 std::is_same< std::string, typename std::decay< T >::type >::value 33 36 > 34 37 {}; … … 57 60 }; 58 61 #endif 62 63 namespace detail 64 { 65 66 template < typename F > 67 struct function_traits_impl 68 { 69 70 }; 71 72 template < typename R > 73 struct function_traits_impl< R (*)(void) > 74 { 75 typedef R (*type)(); 76 typedef R return_type; 77 typedef void class_type; 78 static const int arg_count = 0; 79 }; 80 81 template < typename R, typename T1 > 82 struct function_traits_impl< R (*)( T1 ) > 83 { 84 typedef R (*type)(); 85 typedef R return_type; 86 typedef void class_type; 87 static const int arg_count = 1; 88 }; 89 90 template < typename R, typename T1, typename T2 > 91 struct function_traits_impl< R (*)( T1, T2 ) > 92 { 93 typedef R (*type)(); 94 typedef R return_type; 95 typedef void class_type; 96 static const int arg_count = 2; 97 }; 98 99 template < typename R, typename T1, typename T2, typename T3 > 100 struct function_traits_impl< R (*)( T1, T2, T3 ) > 101 { 102 typedef R (*type)(); 103 typedef R return_type; 104 typedef void class_type; 105 static const int arg_count = 3; 106 }; 107 108 template < typename R, typename T1, typename T2, typename T3, typename T4 > 109 struct function_traits_impl< R (*)( T1, T2, T3, T4 ) > 110 { 111 typedef R (*type)(); 112 typedef R return_type; 113 typedef void class_type; 114 static const int arg_count = 4; 115 }; 116 117 template < class C, typename R > 118 struct function_traits_impl< R (C::*)() > 119 { 120 typedef R (*type)(); 121 typedef R return_type; 122 typedef C class_type; 123 static const int arg_count = 0; 124 }; 125 126 template < class C, typename R, typename T1 > 127 struct function_traits_impl< R (C::*)( T1 ) > 128 { 129 typedef R (*type)(); 130 typedef R return_type; 131 typedef C class_type; 132 static const int arg_count = 1; 133 }; 134 135 template < class C, typename R, typename T1, typename T2 > 136 struct function_traits_impl< R (C::*)( T1, T2 ) > 137 { 138 typedef R (*type)(); 139 typedef R return_type; 140 typedef C class_type; 141 static const int arg_count = 2; 142 }; 143 144 template < class C, typename R, typename T1, typename T2, typename T3 > 145 struct function_traits_impl< R (C::*)( T1, T2, T3 ) > 146 { 147 typedef R (*type)(); 148 typedef R return_type; 149 typedef C class_type; 150 static const int arg_count = 3; 151 }; 152 153 template < class C, typename R, typename T1, typename T2, typename T3, typename T4 > 154 struct function_traits_impl< R (C::*)( T1, T2, T3, T4 ) > 155 { 156 typedef R (*type)(); 157 typedef R return_type; 158 typedef C class_type; 159 static const int arg_count = 4; 160 }; 161 162 } 163 164 template < typename F > 165 struct function_traits : public detail::function_traits_impl< typename std::add_pointer< F >::type > 166 { 167 168 }; 169 170 171 template < typename T > 172 struct return_type 173 { 174 typedef typename function_traits< T >::return_type type; 175 }; 176 177 template < typename T > 178 struct memfn_class_type 179 { 180 typedef typename function_traits< T >::class_type type; 181 }; 182 59 183 } 60 184
Note: See TracChangeset
for help on using the changeset viewer.