OLD | NEW |
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 10 matching lines...) Expand all Loading... |
21 // DispatchToFunction( | 21 // DispatchToFunction( |
22 // &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") | 22 // &SomeFunc, MakeTuple(10, "foo")); // SomeFunc(10, "foo") |
23 // | 23 // |
24 // struct { void SomeMeth(int a, int b, int c) { } } foo; | 24 // struct { void SomeMeth(int a, int b, int c) { } } foo; |
25 // DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); | 25 // DispatchToMethod(&foo, &Foo::SomeMeth, MakeTuple(1, 2, 3)); |
26 // // foo->SomeMeth(1, 2, 3); | 26 // // foo->SomeMeth(1, 2, 3); |
27 | 27 |
28 #ifndef BASE_TUPLE_H_ | 28 #ifndef BASE_TUPLE_H_ |
29 #define BASE_TUPLE_H_ | 29 #define BASE_TUPLE_H_ |
30 | 30 |
| 31 #include <stddef.h> |
| 32 |
31 #include "base/bind_helpers.h" | 33 #include "base/bind_helpers.h" |
| 34 #include "build/build_config.h" |
32 | 35 |
33 namespace base { | 36 namespace base { |
34 | 37 |
35 // Index sequences | 38 // Index sequences |
36 // | 39 // |
37 // Minimal clone of the similarly-named C++14 functionality. | 40 // Minimal clone of the similarly-named C++14 functionality. |
38 | 41 |
39 template <size_t...> | 42 template <size_t...> |
40 struct IndexSequence {}; | 43 struct IndexSequence {}; |
41 | 44 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 const Tuple<InTs...>& in, | 297 const Tuple<InTs...>& in, |
295 Tuple<OutTs...>* out) { | 298 Tuple<OutTs...>* out) { |
296 DispatchToMethodImpl(obj, method, in, out, | 299 DispatchToMethodImpl(obj, method, in, out, |
297 MakeIndexSequence<sizeof...(InTs)>(), | 300 MakeIndexSequence<sizeof...(InTs)>(), |
298 MakeIndexSequence<sizeof...(OutTs)>()); | 301 MakeIndexSequence<sizeof...(OutTs)>()); |
299 } | 302 } |
300 | 303 |
301 } // namespace base | 304 } // namespace base |
302 | 305 |
303 #endif // BASE_TUPLE_H_ | 306 #endif // BASE_TUPLE_H_ |
OLD | NEW |