Changeset daef596 in mainline
- Timestamp:
- 2018-07-05T21:41:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c866a83
- Parents:
- e9f2f4e
- git-author:
- Dzejrou <dzejrou@…> (2018-05-04 21:03:48)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/functional.hpp
re9f2f4e rdaef596 1123 1123 namespace aux 1124 1124 { 1125 template<class F, class... Args> 1125 /** 1126 * Note: Our internal bind return type has an extra type 1127 * template parameter and an extra bool template parameter. 1128 * We use this for the special version of bind that has 1129 * the return type to have a result_type typedef 1130 * (i.e. when the bool is true, the extra type parameter 1131 * is typedefed as result_type - see the structure below). 1132 * This is just a simplification of the implementation 1133 * so that we don't need to have two return types for 1134 * the two bind functions, because unlike function or 1135 * mem_fn, we know exactly when to make the typedef. 1136 */ 1137 1138 template<class, bool = false> 1139 struct bind_conditional_result_type 1140 { /* DUMMY BODY */ }; 1141 1142 template<class R> 1143 struct bind_conditional_result_type<R, true> 1144 { 1145 using result_type = R; 1146 }; 1147 1148 template<class, bool, class, class...> 1126 1149 class bind_t; 1127 1150 … … 1162 1185 } 1163 1186 1164 template<class F, class... BindArgs>1165 constexpr decltype(auto) operator[](const bind_t< F, BindArgs...> b)1187 template<class R, bool B, class F, class... BindArgs> 1188 constexpr decltype(auto) operator[](const bind_t<R, B, F, BindArgs...> b) 1166 1189 { 1167 1190 return b; // TODO: bind subexpressions … … 1173 1196 }; 1174 1197 1175 template<class F, class... Args> 1176 class bind_t 1177 { 1178 // TODO: conditional typedefs 1198 template<class R, bool HasResultType, class F, class... Args> 1199 class bind_t: public bind_conditional_result_type<R, HasResultType> 1200 { 1179 1201 public: 1180 1202 template<class G, class... BoundArgs> … … 1228 1250 { /* DUMMY BODY */ }; 1229 1251 1230 template<class F, class... Args>1231 struct is_bind_expression<aux::bind_t< F, Args...>>1252 template<class R, bool B, class F, class... Args> 1253 struct is_bind_expression<aux::bind_t<R, B, F, Args...>> 1232 1254 : true_type 1233 1255 { /* DUMMY BODY */ }; 1234 1256 1235 1257 template<class F, class... Args> 1236 aux::bind_t< F, Args...> bind(F&& f, Args&&... args)1237 { 1238 return aux::bind_t< F, Args...>{forward<F>(f), forward<Args>(args)...};1258 aux::bind_t<void, false, F, Args...> bind(F&& f, Args&&... args) 1259 { 1260 return aux::bind_t<void, false, F, Args...>{forward<F>(f), forward<Args>(args)...}; 1239 1261 } 1240 1262 1241 1263 template<class R, class F, class... Args> 1242 aux::bind_t<F, Args...> bind(F&& f, Args&&... args) 1243 { 1244 // TODO: this one should have a result_type typedef equal to R 1245 return aux::bind_t<F, Args...>{forward<F>(f), forward<Args>(args)...}; 1264 aux::bind_t<R, true, F, Args...> bind(F&& f, Args&&... args) 1265 { 1266 return aux::bind_t<R, true, F, Args...>{forward<F>(f), forward<Args>(args)...}; 1246 1267 } 1247 1268
Note:
See TracChangeset
for help on using the changeset viewer.