Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: base/tuple.h

Issue 1736643005: Decouple Media Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another try to fix Windows Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/common/content_message_generator.h » ('j') | ipc/ipc_message_templates.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // A Tuple is a generic templatized container, similar in concept to std::pair 5 // A Tuple is a generic templatized container, similar in concept to std::pair
6 // and std::tuple. The convenient MakeTuple() function takes any number of 6 // and std::tuple. The convenient MakeTuple() function takes any number of
7 // arguments and will construct and return the appropriate Tuple object. The 7 // arguments and will construct and return the appropriate Tuple object. The
8 // functions DispatchToMethod and DispatchToFunction take a function pointer or 8 // functions DispatchToMethod and DispatchToFunction take a function pointer or
9 // instance and method pointer, and unpack a tuple into arguments to the call. 9 // instance and method pointer, and unpack a tuple into arguments to the call.
10 // 10 //
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 template <typename Function, typename... Ts> 222 template <typename Function, typename... Ts>
223 inline void DispatchToFunction(Function function, const Tuple<Ts...>& arg) { 223 inline void DispatchToFunction(Function function, const Tuple<Ts...>& arg) {
224 DispatchToFunctionImpl(function, arg, MakeIndexSequence<sizeof...(Ts)>()); 224 DispatchToFunctionImpl(function, arg, MakeIndexSequence<sizeof...(Ts)>());
225 } 225 }
226 226
227 // Dispatchers with out parameters. 227 // Dispatchers with out parameters.
228 228
229 template <typename ObjT, 229 template <typename ObjT,
230 typename Method, 230 typename Method,
231 typename P,
232 typename... InTs,
233 typename... OutTs,
234 size_t... InNs,
235 size_t... OutNs>
236 inline void DispatchToMethodImpl(const ObjT& obj,
237 Method method,
238 P* parameter,
239 const Tuple<InTs...>& in,
240 Tuple<OutTs...>* out,
241 IndexSequence<InNs...>,
242 IndexSequence<OutNs...>) {
243 (obj->*method)(parameter, internal::Unwrap(get<InNs>(in))...,
244 &get<OutNs>(*out)...);
245 }
246
247 template <typename ObjT,
248 typename P,
249 typename... Args,
250 typename... InTs,
251 typename... OutTs,
252 typename std::enable_if<!std::is_void<P>::value>::type* = nullptr>
danakj 2016/03/03 21:00:28 I know you're working around msvc bugs but I don't
253 void DispatchToMethod(ObjT* obj,
254 void (ObjT::*method)(P*, Args...),
255 P* parameter,
256 const base::Tuple<InTs...>& tuple,
257 base::Tuple<OutTs...>* out) {
258 DispatchToMethodImpl(obj, method, parameter, tuple, out,
259 MakeIndexSequence<sizeof...(InTs)>(),
260 MakeIndexSequence<sizeof...(OutTs)>());
261 }
262
263 template <typename ObjT,
264 typename Method,
231 typename... InTs, 265 typename... InTs,
232 typename... OutTs, 266 typename... OutTs,
233 size_t... InNs, 267 size_t... InNs,
234 size_t... OutNs> 268 size_t... OutNs>
235 inline void DispatchToMethodImpl(const ObjT& obj, 269 inline void DispatchToMethodImpl(const ObjT& obj,
236 Method method, 270 Method method,
237 const Tuple<InTs...>& in, 271 const Tuple<InTs...>& in,
238 Tuple<OutTs...>* out, 272 Tuple<OutTs...>* out,
239 IndexSequence<InNs...>, 273 IndexSequence<InNs...>,
240 IndexSequence<OutNs...>) { 274 IndexSequence<OutNs...>) {
241 (obj->*method)(internal::Unwrap(get<InNs>(in))..., &get<OutNs>(*out)...); 275 (obj->*method)(internal::Unwrap(get<InNs>(in))..., &get<OutNs>(*out)...);
242 } 276 }
243 277
244 template <typename ObjT, typename Method, typename... InTs, typename... OutTs> 278 template <typename ObjT,
279 typename Method,
280 typename P,
281 typename... InTs,
282 typename... OutTs>
245 inline void DispatchToMethod(const ObjT& obj, 283 inline void DispatchToMethod(const ObjT& obj,
246 Method method, 284 Method method,
285 P* parameter,
247 const Tuple<InTs...>& in, 286 const Tuple<InTs...>& in,
248 Tuple<OutTs...>* out) { 287 Tuple<OutTs...>* out) {
249 DispatchToMethodImpl(obj, method, in, out, 288 DispatchToMethodImpl(obj, method, in, out,
250 MakeIndexSequence<sizeof...(InTs)>(), 289 MakeIndexSequence<sizeof...(InTs)>(),
251 MakeIndexSequence<sizeof...(OutTs)>()); 290 MakeIndexSequence<sizeof...(OutTs)>());
252 } 291 }
253 292
254 } // namespace base 293 } // namespace base
255 294
256 #endif // BASE_TUPLE_H_ 295 #endif // BASE_TUPLE_H_
OLDNEW
« no previous file with comments | « no previous file | content/common/content_message_generator.h » ('j') | ipc/ipc_message_templates.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698