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

Side by Side Diff: base/tuple.h

Issue 1462443002: Mark base::Tuple as final (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 | printing/pdf_render_settings.h » ('j') | no next file with comments »
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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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_
OLDNEW
« no previous file with comments | « no previous file | printing/pdf_render_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698