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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 template <> struct MakeIndexSequenceImpl<11> { | 87 template <> struct MakeIndexSequenceImpl<11> { |
88 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10>; | 88 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10>; |
89 }; | 89 }; |
90 template <> struct MakeIndexSequenceImpl<12> { | 90 template <> struct MakeIndexSequenceImpl<12> { |
91 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10,11>; | 91 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10,11>; |
92 }; | 92 }; |
93 template <> struct MakeIndexSequenceImpl<13> { | 93 template <> struct MakeIndexSequenceImpl<13> { |
94 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10,11,12>; | 94 using Type = IndexSequence<0,1,2,3,4,5,6,7,8,9,10,11,12>; |
95 }; | 95 }; |
96 | 96 |
97 #else // defined(WIN) && defined(_PREFAST_) | 97 #else // defined(OS_WIN) && defined(_PREFAST_) |
98 | 98 |
99 template <size_t... Ns> | 99 template <size_t... Ns> |
100 struct MakeIndexSequenceImpl<0, Ns...> { | 100 struct MakeIndexSequenceImpl<0, Ns...> { |
101 using Type = IndexSequence<Ns...>; | 101 using Type = IndexSequence<Ns...>; |
102 }; | 102 }; |
103 | 103 |
104 template <size_t N, size_t... Ns> | 104 template <size_t N, size_t... Ns> |
105 struct MakeIndexSequenceImpl<N, Ns...> | 105 struct MakeIndexSequenceImpl<N, Ns...> |
106 : MakeIndexSequenceImpl<N - 1, N - 1, Ns...> {}; | 106 : MakeIndexSequenceImpl<N - 1, N - 1, Ns...> {}; |
107 | 107 |
108 #endif // defined(WIN) && defined(_PREFAST_) | 108 #endif // defined(OS_WIN) && defined(_PREFAST_) |
109 | 109 |
110 template <size_t N> | 110 template <size_t N> |
111 using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type; | 111 using MakeIndexSequence = typename MakeIndexSequenceImpl<N>::Type; |
112 | 112 |
113 // Tuple ----------------------------------------------------------------------- | 113 // Tuple ----------------------------------------------------------------------- |
114 // | 114 // |
115 // This set of classes is useful for bundling 0 or more heterogeneous data types | 115 // This set of classes is useful for bundling 0 or more heterogeneous data types |
116 // into a single variable. The advantage of this is that it greatly simplifies | 116 // into a single variable. The advantage of this is that it greatly simplifies |
117 // function objects that need to take an arbitrary number of parameters; see | 117 // function objects that need to take an arbitrary number of parameters; see |
118 // RunnableMethod and IPC::MessageWithTuple. | 118 // RunnableMethod and IPC::MessageWithTuple. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 const Tuple<InTs...>& in, | 210 const Tuple<InTs...>& in, |
211 Tuple<OutTs...>* out) { | 211 Tuple<OutTs...>* out) { |
212 DispatchToMethodImpl(obj, method, in, out, | 212 DispatchToMethodImpl(obj, method, in, out, |
213 MakeIndexSequence<sizeof...(InTs)>(), | 213 MakeIndexSequence<sizeof...(InTs)>(), |
214 MakeIndexSequence<sizeof...(OutTs)>()); | 214 MakeIndexSequence<sizeof...(OutTs)>()); |
215 } | 215 } |
216 | 216 |
217 } // namespace base | 217 } // namespace base |
218 | 218 |
219 #endif // BASE_TUPLE_H_ | 219 #endif // BASE_TUPLE_H_ |
OLD | NEW |