| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // output (a "tier"). See MakeRefTuple and its usages. | 143 // output (a "tier"). See MakeRefTuple and its usages. |
| 144 | 144 |
| 145 template <typename IxSeq, typename... Ts> | 145 template <typename IxSeq, typename... Ts> |
| 146 struct TupleBaseImpl; | 146 struct TupleBaseImpl; |
| 147 template <typename... Ts> | 147 template <typename... Ts> |
| 148 using TupleBase = TupleBaseImpl<MakeIndexSequence<sizeof...(Ts)>, Ts...>; | 148 using TupleBase = TupleBaseImpl<MakeIndexSequence<sizeof...(Ts)>, Ts...>; |
| 149 template <size_t N, typename T> | 149 template <size_t N, typename T> |
| 150 struct TupleLeaf; | 150 struct TupleLeaf; |
| 151 | 151 |
| 152 template <typename... Ts> | 152 template <typename... Ts> |
| 153 struct Tuple : TupleBase<Ts...> { | 153 struct Tuple final : TupleBase<Ts...> { |
| 154 Tuple() : TupleBase<Ts...>() {} | 154 Tuple() : TupleBase<Ts...>() {} |
| 155 explicit Tuple(typename TupleTraits<Ts>::ParamType... args) | 155 explicit Tuple(typename TupleTraits<Ts>::ParamType... args) |
| 156 : TupleBase<Ts...>(args...) {} | 156 : TupleBase<Ts...>(args...) {} |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 // Avoids ambiguity between Tuple's two constructors. | 159 // Avoids ambiguity between Tuple's two constructors. |
| 160 template <> | 160 template <> |
| 161 struct Tuple<> {}; | 161 struct Tuple<> final {}; |
| 162 | 162 |
| 163 template <size_t... Ns, typename... Ts> | 163 template <size_t... Ns, typename... Ts> |
| 164 struct TupleBaseImpl<IndexSequence<Ns...>, Ts...> : TupleLeaf<Ns, Ts>... { | 164 struct TupleBaseImpl<IndexSequence<Ns...>, Ts...> : TupleLeaf<Ns, Ts>... { |
| 165 TupleBaseImpl() : TupleLeaf<Ns, Ts>()... {} | 165 TupleBaseImpl() : TupleLeaf<Ns, Ts>()... {} |
| 166 explicit TupleBaseImpl(typename TupleTraits<Ts>::ParamType... args) | 166 explicit TupleBaseImpl(typename TupleTraits<Ts>::ParamType... args) |
| 167 : TupleLeaf<Ns, Ts>(args)... {} | 167 : TupleLeaf<Ns, Ts>(args)... {} |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 template <size_t N, typename T> | 170 template <size_t N, typename T> |
| 171 struct TupleLeaf { | 171 struct TupleLeaf { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 const Tuple<InTs...>& in, | 327 const Tuple<InTs...>& in, |
| 328 Tuple<OutTs...>* out) { | 328 Tuple<OutTs...>* out) { |
| 329 DispatchToMethodImpl(obj, method, in, out, | 329 DispatchToMethodImpl(obj, method, in, out, |
| 330 MakeIndexSequence<sizeof...(InTs)>(), | 330 MakeIndexSequence<sizeof...(InTs)>(), |
| 331 MakeIndexSequence<sizeof...(OutTs)>()); | 331 MakeIndexSequence<sizeof...(OutTs)>()); |
| 332 } | 332 } |
| 333 | 333 |
| 334 } // namespace base | 334 } // namespace base |
| 335 | 335 |
| 336 #endif // BASE_TUPLE_H_ | 336 #endif // BASE_TUPLE_H_ |
| OLD | NEW |