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

Side by Side Diff: base/tuple.h

Issue 863253002: Update from https://crrev.com/312600 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 22 matching lines...) Expand all
33 // Index sequences 33 // Index sequences
34 // 34 //
35 // Minimal clone of the similarly-named C++14 functionality. 35 // Minimal clone of the similarly-named C++14 functionality.
36 36
37 template <size_t...> 37 template <size_t...>
38 struct IndexSequence {}; 38 struct IndexSequence {};
39 39
40 template <size_t... Ns> 40 template <size_t... Ns>
41 struct MakeIndexSequenceImpl; 41 struct MakeIndexSequenceImpl;
42 42
43 #if defined(_PREFAST_) && defined(OS_WIN)
44
45 // Work around VC++ 2013 /analyze internal compiler error:
46 // https://connect.microsoft.com/VisualStudio/feedback/details/1053626
47
48 template <> struct MakeIndexSequenceImpl<0> {
49 using Type = IndexSequence<>;
50 };
51 template <> struct MakeIndexSequenceImpl<1> {
52 using Type = IndexSequence<0>;
53 };
54 template <> struct MakeIndexSequenceImpl<2> {
55 using Type = IndexSequence<0,1>;
56 };
57 template <> struct MakeIndexSequenceImpl<3> {
58 using Type = IndexSequence<0,1,2>;
59 };
60 template <> struct MakeIndexSequenceImpl<4> {
61 using Type = IndexSequence<0,1,2,3>;
62 };
63 template <> struct MakeIndexSequenceImpl<5> {
64 using Type = IndexSequence<0,1,2,3,4>;
65 };
66 template <> struct MakeIndexSequenceImpl<6> {
67 using Type = IndexSequence<0,1,2,3,4,5>;
68 };
69 template <> struct MakeIndexSequenceImpl<7> {
70 using Type = IndexSequence<0,1,2,3,4,5,6>;
71 };
72 template <> struct MakeIndexSequenceImpl<8> {
73 using Type = IndexSequence<0,1,2,3,4,5,6,7>;
74 };
75 template <> struct MakeIndexSequenceImpl<9> {
76 using Type = IndexSequence<0,1,2,3,4,5,6,7,8>;
77 };
78 template <> struct MakeIndexSequenceImpl<10> {
79 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9>;
80 };
81 template <> struct MakeIndexSequenceImpl<11> {
82 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10>;
83 };
84
85 #else // defined(WIN) && defined(_PREFAST_)
86
43 template <size_t... Ns> 87 template <size_t... Ns>
44 struct MakeIndexSequenceImpl<0, Ns...> { 88 struct MakeIndexSequenceImpl<0, Ns...> {
45 using Type = IndexSequence<Ns...>; 89 using Type = IndexSequence<Ns...>;
46 }; 90 };
47 91
48 template <size_t N, size_t... Ns> 92 template <size_t N, size_t... Ns>
49 struct MakeIndexSequenceImpl<N, Ns...> 93 struct MakeIndexSequenceImpl<N, Ns...>
50 : MakeIndexSequenceImpl<N - 1, N - 1, Ns...> {}; 94 : MakeIndexSequenceImpl<N - 1, N - 1, Ns...> {};
51 95
96 #endif // defined(WIN) && defined(_PREFAST_)
97
52 template <size_t N> 98 template <size_t N>
53 using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type; 99 using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type;
54 100
55 // Traits ---------------------------------------------------------------------- 101 // Traits ----------------------------------------------------------------------
56 // 102 //
57 // A simple traits class for tuple arguments. 103 // A simple traits class for tuple arguments.
58 // 104 //
59 // ValueType: the bare, nonref version of a type (same as the type for nonrefs). 105 // ValueType: the bare, nonref version of a type (same as the type for nonrefs).
60 // RefType: the ref version of a type (same as the type for refs). 106 // RefType: the ref version of a type (same as the type for refs).
61 // ParamType: what type to pass to functions (refs should not be constified). 107 // ParamType: what type to pass to functions (refs should not be constified).
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 inline void DispatchToMethod(ObjT* obj, 317 inline void DispatchToMethod(ObjT* obj,
272 Method method, 318 Method method,
273 const Tuple<InTs...>& in, 319 const Tuple<InTs...>& in,
274 Tuple<OutTs...>* out) { 320 Tuple<OutTs...>* out) {
275 DispatchToMethodImpl(obj, method, in, out, 321 DispatchToMethodImpl(obj, method, in, out,
276 MakeIndexSequence<sizeof...(InTs)>(), 322 MakeIndexSequence<sizeof...(InTs)>(),
277 MakeIndexSequence<sizeof...(OutTs)>()); 323 MakeIndexSequence<sizeof...(OutTs)>());
278 } 324 }
279 325
280 #endif // BASE_TUPLE_H__ 326 #endif // BASE_TUPLE_H__
OLDNEW
« no previous file with comments | « base/test/launcher/unit_test_launcher.cc ('k') | build/all.gyp » ('j') | testing/test.gni » ('J')

Powered by Google App Engine
This is Rietveld 408576698