| 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 // Use std::tuple as tuple type. This file contains helper functions for | 5 // Use std::tuple as tuple type. This file contains helper functions for |
| 6 // working with std::tuples. | 6 // working with std::tuples. |
| 7 // The functions DispatchToMethod and DispatchToFunction take a function pointer | 7 // The functions DispatchToMethod and DispatchToFunction take a function pointer |
| 8 // or instance and method pointer, and unpack a tuple into arguments to the | 8 // or instance and method pointer, and unpack a tuple into arguments to the |
| 9 // call. | 9 // call. |
| 10 // | 10 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // struct { void SomeMeth(int a, int b, int c) { } } foo; | 21 // struct { void SomeMeth(int a, int b, int c) { } } foo; |
| 22 // DispatchToMethod(&foo, &Foo::SomeMeth, std::make_tuple(1, 2, 3)); | 22 // DispatchToMethod(&foo, &Foo::SomeMeth, std::make_tuple(1, 2, 3)); |
| 23 // // foo->SomeMeth(1, 2, 3); | 23 // // foo->SomeMeth(1, 2, 3); |
| 24 | 24 |
| 25 #ifndef BASE_TUPLE_H_ | 25 #ifndef BASE_TUPLE_H_ |
| 26 #define BASE_TUPLE_H_ | 26 #define BASE_TUPLE_H_ |
| 27 | 27 |
| 28 #include <stddef.h> | 28 #include <stddef.h> |
| 29 #include <tuple> | 29 #include <tuple> |
| 30 | 30 |
| 31 #include "base/bind_helpers.h" | |
| 32 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 33 | 32 |
| 34 namespace base { | 33 namespace base { |
| 35 | 34 |
| 36 // Index sequences | 35 // Index sequences |
| 37 // | 36 // |
| 38 // Minimal clone of the similarly-named C++14 functionality. | 37 // Minimal clone of the similarly-named C++14 functionality. |
| 39 | 38 |
| 40 template <size_t...> | 39 template <size_t...> |
| 41 struct IndexSequence {}; | 40 struct IndexSequence {}; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 InTuple&& in, | 190 InTuple&& in, |
| 192 OutTuple* out) { | 191 OutTuple* out) { |
| 193 DispatchToMethodImpl(obj, method, std::forward<InTuple>(in), out, | 192 DispatchToMethodImpl(obj, method, std::forward<InTuple>(in), out, |
| 194 MakeIndexSequenceForTuple<InTuple>(), | 193 MakeIndexSequenceForTuple<InTuple>(), |
| 195 MakeIndexSequenceForTuple<OutTuple>()); | 194 MakeIndexSequenceForTuple<OutTuple>()); |
| 196 } | 195 } |
| 197 | 196 |
| 198 } // namespace base | 197 } // namespace base |
| 199 | 198 |
| 200 #endif // BASE_TUPLE_H_ | 199 #endif // BASE_TUPLE_H_ |
| OLD | NEW |