1 // This file was GENERATED by a script. DO NOT EDIT BY HAND!!!
3 // Copyright 2009 Google Inc.
4 // All Rights Reserved.
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following disclaimer
14 // in the documentation and/or other materials provided with the
16 // * Neither the name of Google Inc. nor the names of its
17 // contributors may be used to endorse or promote products derived from
18 // this software without specific prior written permission.
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 // Author: wan@google.com (Zhanyong Wan)
34 // Implements a subset of TR1 tuple needed by Google Test and Google Mock.
36 #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
37 #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
39 #include <utility> // For ::std::pair.
41 // The compiler used in Symbian has a bug that prevents us from declaring the
42 // tuple template as a friend (it complains that tuple is redefined). This
43 // hack bypasses the bug by declaring the members that should otherwise be
45 // Sun Studio versions < 12 also have the above bug.
46 #if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
47 #define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
49 #define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
50 template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
54 // GTEST_n_TUPLE_(T) is the type of an n-tuple.
55 #define GTEST_0_TUPLE_(T) tuple<>
56 #define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
58 #define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
60 #define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
62 #define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
64 #define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
66 #define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
68 #define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
70 #define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
72 #define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
74 #define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
77 // GTEST_n_TYPENAMES_(T) declares a list of n typenames.
78 #define GTEST_0_TYPENAMES_(T)
79 #define GTEST_1_TYPENAMES_(T) typename T##0
80 #define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
81 #define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
82 #define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
84 #define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
85 typename T##3, typename T##4
86 #define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
87 typename T##3, typename T##4, typename T##5
88 #define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
89 typename T##3, typename T##4, typename T##5, typename T##6
90 #define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
91 typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
92 #define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
93 typename T##3, typename T##4, typename T##5, typename T##6, \
94 typename T##7, typename T##8
95 #define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
96 typename T##3, typename T##4, typename T##5, typename T##6, \
97 typename T##7, typename T##8, typename T##9
99 // In theory, defining stuff in the ::std namespace is undefined
100 // behavior. We can do this as we are playing the role of a standard
105 template <typename T0
= void, typename T1
= void, typename T2
= void,
106 typename T3
= void, typename T4
= void, typename T5
= void,
107 typename T6
= void, typename T7
= void, typename T8
= void,
111 // Anything in namespace gtest_internal is Google Test's INTERNAL
112 // IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
113 namespace gtest_internal
{
115 // ByRef<T>::type is T if T is a reference; otherwise it's const T&.
116 template <typename T
>
117 struct ByRef
{ typedef const T
& type
; }; // NOLINT
118 template <typename T
>
119 struct ByRef
<T
&> { typedef T
& type
; }; // NOLINT
121 // A handy wrapper for ByRef.
122 #define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
124 // AddRef<T>::type is T if T is a reference; otherwise it's T&. This
125 // is the same as tr1::add_reference<T>::type.
126 template <typename T
>
127 struct AddRef
{ typedef T
& type
; }; // NOLINT
128 template <typename T
>
129 struct AddRef
<T
&> { typedef T
& type
; }; // NOLINT
131 // A handy wrapper for AddRef.
132 #define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
134 // A helper for implementing get<k>().
135 template <int k
> class Get
;
137 // A helper for implementing tuple_element<k, T>. kIndexValid is true
138 // iff k < the number of fields in tuple type T.
139 template <bool kIndexValid
, int kIndex
, class Tuple
>
142 template <GTEST_10_TYPENAMES_(T
)>
143 struct TupleElement
<true, 0, GTEST_10_TUPLE_(T
)> { typedef T0 type
; };
145 template <GTEST_10_TYPENAMES_(T
)>
146 struct TupleElement
<true, 1, GTEST_10_TUPLE_(T
)> { typedef T1 type
; };
148 template <GTEST_10_TYPENAMES_(T
)>
149 struct TupleElement
<true, 2, GTEST_10_TUPLE_(T
)> { typedef T2 type
; };
151 template <GTEST_10_TYPENAMES_(T
)>
152 struct TupleElement
<true, 3, GTEST_10_TUPLE_(T
)> { typedef T3 type
; };
154 template <GTEST_10_TYPENAMES_(T
)>
155 struct TupleElement
<true, 4, GTEST_10_TUPLE_(T
)> { typedef T4 type
; };
157 template <GTEST_10_TYPENAMES_(T
)>
158 struct TupleElement
<true, 5, GTEST_10_TUPLE_(T
)> { typedef T5 type
; };
160 template <GTEST_10_TYPENAMES_(T
)>
161 struct TupleElement
<true, 6, GTEST_10_TUPLE_(T
)> { typedef T6 type
; };
163 template <GTEST_10_TYPENAMES_(T
)>
164 struct TupleElement
<true, 7, GTEST_10_TUPLE_(T
)> { typedef T7 type
; };
166 template <GTEST_10_TYPENAMES_(T
)>
167 struct TupleElement
<true, 8, GTEST_10_TUPLE_(T
)> { typedef T8 type
; };
169 template <GTEST_10_TYPENAMES_(T
)>
170 struct TupleElement
<true, 9, GTEST_10_TUPLE_(T
)> { typedef T9 type
; };
172 } // namespace gtest_internal
178 tuple(const tuple
& /* t */) {}
179 tuple
& operator=(const tuple
& /* t */) { return *this; }
182 template <GTEST_1_TYPENAMES_(T
)>
183 class GTEST_1_TUPLE_(T
) {
185 template <int k
> friend class gtest_internal::Get
;
189 explicit tuple(GTEST_BY_REF_(T0
) f0
) : f0_(f0
) {}
191 tuple(const tuple
& t
) : f0_(t
.f0_
) {}
193 template <GTEST_1_TYPENAMES_(U
)>
194 tuple(const GTEST_1_TUPLE_(U
)& t
) : f0_(t
.f0_
) {}
196 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
198 template <GTEST_1_TYPENAMES_(U
)>
199 tuple
& operator=(const GTEST_1_TUPLE_(U
)& t
) {
203 GTEST_DECLARE_TUPLE_AS_FRIEND_
205 template <GTEST_1_TYPENAMES_(U
)>
206 tuple
& CopyFrom(const GTEST_1_TUPLE_(U
)& t
) {
214 template <GTEST_2_TYPENAMES_(T
)>
215 class GTEST_2_TUPLE_(T
) {
217 template <int k
> friend class gtest_internal::Get
;
219 tuple() : f0_(), f1_() {}
221 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
) : f0_(f0
),
224 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
) {}
226 template <GTEST_2_TYPENAMES_(U
)>
227 tuple(const GTEST_2_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
) {}
228 template <typename U0
, typename U1
>
229 tuple(const ::std::pair
<U0
, U1
>& p
) : f0_(p
.first
), f1_(p
.second
) {}
231 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
233 template <GTEST_2_TYPENAMES_(U
)>
234 tuple
& operator=(const GTEST_2_TUPLE_(U
)& t
) {
237 template <typename U0
, typename U1
>
238 tuple
& operator=(const ::std::pair
<U0
, U1
>& p
) {
244 GTEST_DECLARE_TUPLE_AS_FRIEND_
246 template <GTEST_2_TYPENAMES_(U
)>
247 tuple
& CopyFrom(const GTEST_2_TUPLE_(U
)& t
) {
257 template <GTEST_3_TYPENAMES_(T
)>
258 class GTEST_3_TUPLE_(T
) {
260 template <int k
> friend class gtest_internal::Get
;
262 tuple() : f0_(), f1_(), f2_() {}
264 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
265 GTEST_BY_REF_(T2
) f2
) : f0_(f0
), f1_(f1
), f2_(f2
) {}
267 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
) {}
269 template <GTEST_3_TYPENAMES_(U
)>
270 tuple(const GTEST_3_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
) {}
272 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
274 template <GTEST_3_TYPENAMES_(U
)>
275 tuple
& operator=(const GTEST_3_TUPLE_(U
)& t
) {
279 GTEST_DECLARE_TUPLE_AS_FRIEND_
281 template <GTEST_3_TYPENAMES_(U
)>
282 tuple
& CopyFrom(const GTEST_3_TUPLE_(U
)& t
) {
294 template <GTEST_4_TYPENAMES_(T
)>
295 class GTEST_4_TUPLE_(T
) {
297 template <int k
> friend class gtest_internal::Get
;
299 tuple() : f0_(), f1_(), f2_(), f3_() {}
301 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
302 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
) : f0_(f0
), f1_(f1
), f2_(f2
),
305 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
) {}
307 template <GTEST_4_TYPENAMES_(U
)>
308 tuple(const GTEST_4_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
311 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
313 template <GTEST_4_TYPENAMES_(U
)>
314 tuple
& operator=(const GTEST_4_TUPLE_(U
)& t
) {
318 GTEST_DECLARE_TUPLE_AS_FRIEND_
320 template <GTEST_4_TYPENAMES_(U
)>
321 tuple
& CopyFrom(const GTEST_4_TUPLE_(U
)& t
) {
335 template <GTEST_5_TYPENAMES_(T
)>
336 class GTEST_5_TUPLE_(T
) {
338 template <int k
> friend class gtest_internal::Get
;
340 tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
342 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
343 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
,
344 GTEST_BY_REF_(T4
) f4
) : f0_(f0
), f1_(f1
), f2_(f2
), f3_(f3
), f4_(f4
) {}
346 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
349 template <GTEST_5_TYPENAMES_(U
)>
350 tuple(const GTEST_5_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
351 f3_(t
.f3_
), f4_(t
.f4_
) {}
353 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
355 template <GTEST_5_TYPENAMES_(U
)>
356 tuple
& operator=(const GTEST_5_TUPLE_(U
)& t
) {
360 GTEST_DECLARE_TUPLE_AS_FRIEND_
362 template <GTEST_5_TYPENAMES_(U
)>
363 tuple
& CopyFrom(const GTEST_5_TUPLE_(U
)& t
) {
379 template <GTEST_6_TYPENAMES_(T
)>
380 class GTEST_6_TUPLE_(T
) {
382 template <int k
> friend class gtest_internal::Get
;
384 tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
386 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
387 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
, GTEST_BY_REF_(T4
) f4
,
388 GTEST_BY_REF_(T5
) f5
) : f0_(f0
), f1_(f1
), f2_(f2
), f3_(f3
), f4_(f4
),
391 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
392 f4_(t
.f4_
), f5_(t
.f5_
) {}
394 template <GTEST_6_TYPENAMES_(U
)>
395 tuple(const GTEST_6_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
396 f3_(t
.f3_
), f4_(t
.f4_
), f5_(t
.f5_
) {}
398 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
400 template <GTEST_6_TYPENAMES_(U
)>
401 tuple
& operator=(const GTEST_6_TUPLE_(U
)& t
) {
405 GTEST_DECLARE_TUPLE_AS_FRIEND_
407 template <GTEST_6_TYPENAMES_(U
)>
408 tuple
& CopyFrom(const GTEST_6_TUPLE_(U
)& t
) {
426 template <GTEST_7_TYPENAMES_(T
)>
427 class GTEST_7_TUPLE_(T
) {
429 template <int k
> friend class gtest_internal::Get
;
431 tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
433 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
434 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
, GTEST_BY_REF_(T4
) f4
,
435 GTEST_BY_REF_(T5
) f5
, GTEST_BY_REF_(T6
) f6
) : f0_(f0
), f1_(f1
), f2_(f2
),
436 f3_(f3
), f4_(f4
), f5_(f5
), f6_(f6
) {}
438 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
439 f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
) {}
441 template <GTEST_7_TYPENAMES_(U
)>
442 tuple(const GTEST_7_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
443 f3_(t
.f3_
), f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
) {}
445 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
447 template <GTEST_7_TYPENAMES_(U
)>
448 tuple
& operator=(const GTEST_7_TUPLE_(U
)& t
) {
452 GTEST_DECLARE_TUPLE_AS_FRIEND_
454 template <GTEST_7_TYPENAMES_(U
)>
455 tuple
& CopyFrom(const GTEST_7_TUPLE_(U
)& t
) {
475 template <GTEST_8_TYPENAMES_(T
)>
476 class GTEST_8_TUPLE_(T
) {
478 template <int k
> friend class gtest_internal::Get
;
480 tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
482 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
483 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
, GTEST_BY_REF_(T4
) f4
,
484 GTEST_BY_REF_(T5
) f5
, GTEST_BY_REF_(T6
) f6
,
485 GTEST_BY_REF_(T7
) f7
) : f0_(f0
), f1_(f1
), f2_(f2
), f3_(f3
), f4_(f4
),
486 f5_(f5
), f6_(f6
), f7_(f7
) {}
488 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
489 f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
) {}
491 template <GTEST_8_TYPENAMES_(U
)>
492 tuple(const GTEST_8_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
493 f3_(t
.f3_
), f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
) {}
495 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
497 template <GTEST_8_TYPENAMES_(U
)>
498 tuple
& operator=(const GTEST_8_TUPLE_(U
)& t
) {
502 GTEST_DECLARE_TUPLE_AS_FRIEND_
504 template <GTEST_8_TYPENAMES_(U
)>
505 tuple
& CopyFrom(const GTEST_8_TUPLE_(U
)& t
) {
527 template <GTEST_9_TYPENAMES_(T
)>
528 class GTEST_9_TUPLE_(T
) {
530 template <int k
> friend class gtest_internal::Get
;
532 tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
534 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
535 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
, GTEST_BY_REF_(T4
) f4
,
536 GTEST_BY_REF_(T5
) f5
, GTEST_BY_REF_(T6
) f6
, GTEST_BY_REF_(T7
) f7
,
537 GTEST_BY_REF_(T8
) f8
) : f0_(f0
), f1_(f1
), f2_(f2
), f3_(f3
), f4_(f4
),
538 f5_(f5
), f6_(f6
), f7_(f7
), f8_(f8
) {}
540 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
541 f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
), f8_(t
.f8_
) {}
543 template <GTEST_9_TYPENAMES_(U
)>
544 tuple(const GTEST_9_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
545 f3_(t
.f3_
), f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
), f8_(t
.f8_
) {}
547 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
549 template <GTEST_9_TYPENAMES_(U
)>
550 tuple
& operator=(const GTEST_9_TUPLE_(U
)& t
) {
554 GTEST_DECLARE_TUPLE_AS_FRIEND_
556 template <GTEST_9_TYPENAMES_(U
)>
557 tuple
& CopyFrom(const GTEST_9_TUPLE_(U
)& t
) {
581 template <GTEST_10_TYPENAMES_(T
)>
584 template <int k
> friend class gtest_internal::Get
;
586 tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
589 explicit tuple(GTEST_BY_REF_(T0
) f0
, GTEST_BY_REF_(T1
) f1
,
590 GTEST_BY_REF_(T2
) f2
, GTEST_BY_REF_(T3
) f3
, GTEST_BY_REF_(T4
) f4
,
591 GTEST_BY_REF_(T5
) f5
, GTEST_BY_REF_(T6
) f6
, GTEST_BY_REF_(T7
) f7
,
592 GTEST_BY_REF_(T8
) f8
, GTEST_BY_REF_(T9
) f9
) : f0_(f0
), f1_(f1
), f2_(f2
),
593 f3_(f3
), f4_(f4
), f5_(f5
), f6_(f6
), f7_(f7
), f8_(f8
), f9_(f9
) {}
595 tuple(const tuple
& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
), f3_(t
.f3_
),
596 f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
), f8_(t
.f8_
), f9_(t
.f9_
) {}
598 template <GTEST_10_TYPENAMES_(U
)>
599 tuple(const GTEST_10_TUPLE_(U
)& t
) : f0_(t
.f0_
), f1_(t
.f1_
), f2_(t
.f2_
),
600 f3_(t
.f3_
), f4_(t
.f4_
), f5_(t
.f5_
), f6_(t
.f6_
), f7_(t
.f7_
), f8_(t
.f8_
),
603 tuple
& operator=(const tuple
& t
) { return CopyFrom(t
); }
605 template <GTEST_10_TYPENAMES_(U
)>
606 tuple
& operator=(const GTEST_10_TUPLE_(U
)& t
) {
610 GTEST_DECLARE_TUPLE_AS_FRIEND_
612 template <GTEST_10_TYPENAMES_(U
)>
613 tuple
& CopyFrom(const GTEST_10_TUPLE_(U
)& t
) {
639 // 6.1.3.2 Tuple creation functions.
641 // Known limitations: we don't support passing an
642 // std::tr1::reference_wrapper<T> to make_tuple(). And we don't
645 inline tuple
<> make_tuple() { return tuple
<>(); }
647 template <GTEST_1_TYPENAMES_(T
)>
648 inline GTEST_1_TUPLE_(T
) make_tuple(const T0
& f0
) {
649 return GTEST_1_TUPLE_(T
)(f0
);
652 template <GTEST_2_TYPENAMES_(T
)>
653 inline GTEST_2_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
) {
654 return GTEST_2_TUPLE_(T
)(f0
, f1
);
657 template <GTEST_3_TYPENAMES_(T
)>
658 inline GTEST_3_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
) {
659 return GTEST_3_TUPLE_(T
)(f0
, f1
, f2
);
662 template <GTEST_4_TYPENAMES_(T
)>
663 inline GTEST_4_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
665 return GTEST_4_TUPLE_(T
)(f0
, f1
, f2
, f3
);
668 template <GTEST_5_TYPENAMES_(T
)>
669 inline GTEST_5_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
670 const T3
& f3
, const T4
& f4
) {
671 return GTEST_5_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
);
674 template <GTEST_6_TYPENAMES_(T
)>
675 inline GTEST_6_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
676 const T3
& f3
, const T4
& f4
, const T5
& f5
) {
677 return GTEST_6_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
, f5
);
680 template <GTEST_7_TYPENAMES_(T
)>
681 inline GTEST_7_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
682 const T3
& f3
, const T4
& f4
, const T5
& f5
, const T6
& f6
) {
683 return GTEST_7_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
, f5
, f6
);
686 template <GTEST_8_TYPENAMES_(T
)>
687 inline GTEST_8_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
688 const T3
& f3
, const T4
& f4
, const T5
& f5
, const T6
& f6
, const T7
& f7
) {
689 return GTEST_8_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
, f5
, f6
, f7
);
692 template <GTEST_9_TYPENAMES_(T
)>
693 inline GTEST_9_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
694 const T3
& f3
, const T4
& f4
, const T5
& f5
, const T6
& f6
, const T7
& f7
,
696 return GTEST_9_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
, f5
, f6
, f7
, f8
);
699 template <GTEST_10_TYPENAMES_(T
)>
700 inline GTEST_10_TUPLE_(T
) make_tuple(const T0
& f0
, const T1
& f1
, const T2
& f2
,
701 const T3
& f3
, const T4
& f4
, const T5
& f5
, const T6
& f6
, const T7
& f7
,
702 const T8
& f8
, const T9
& f9
) {
703 return GTEST_10_TUPLE_(T
)(f0
, f1
, f2
, f3
, f4
, f5
, f6
, f7
, f8
, f9
);
706 // 6.1.3.3 Tuple helper classes.
708 template <typename Tuple
> struct tuple_size
;
710 template <GTEST_0_TYPENAMES_(T
)>
711 struct tuple_size
<GTEST_0_TUPLE_(T
)> { static const int value
= 0; };
713 template <GTEST_1_TYPENAMES_(T
)>
714 struct tuple_size
<GTEST_1_TUPLE_(T
)> { static const int value
= 1; };
716 template <GTEST_2_TYPENAMES_(T
)>
717 struct tuple_size
<GTEST_2_TUPLE_(T
)> { static const int value
= 2; };
719 template <GTEST_3_TYPENAMES_(T
)>
720 struct tuple_size
<GTEST_3_TUPLE_(T
)> { static const int value
= 3; };
722 template <GTEST_4_TYPENAMES_(T
)>
723 struct tuple_size
<GTEST_4_TUPLE_(T
)> { static const int value
= 4; };
725 template <GTEST_5_TYPENAMES_(T
)>
726 struct tuple_size
<GTEST_5_TUPLE_(T
)> { static const int value
= 5; };
728 template <GTEST_6_TYPENAMES_(T
)>
729 struct tuple_size
<GTEST_6_TUPLE_(T
)> { static const int value
= 6; };
731 template <GTEST_7_TYPENAMES_(T
)>
732 struct tuple_size
<GTEST_7_TUPLE_(T
)> { static const int value
= 7; };
734 template <GTEST_8_TYPENAMES_(T
)>
735 struct tuple_size
<GTEST_8_TUPLE_(T
)> { static const int value
= 8; };
737 template <GTEST_9_TYPENAMES_(T
)>
738 struct tuple_size
<GTEST_9_TUPLE_(T
)> { static const int value
= 9; };
740 template <GTEST_10_TYPENAMES_(T
)>
741 struct tuple_size
<GTEST_10_TUPLE_(T
)> { static const int value
= 10; };
743 template <int k
, class Tuple
>
744 struct tuple_element
{
745 typedef typename
gtest_internal::TupleElement
<
746 k
< (tuple_size
<Tuple
>::value
), k
, Tuple
>::type type
;
749 #define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
751 // 6.1.3.4 Element access.
753 namespace gtest_internal
{
758 template <class Tuple
>
759 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple
))
760 Field(Tuple
& t
) { return t
.f0_
; } // NOLINT
762 template <class Tuple
>
763 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple
))
764 ConstField(const Tuple
& t
) { return t
.f0_
; }
770 template <class Tuple
>
771 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple
))
772 Field(Tuple
& t
) { return t
.f1_
; } // NOLINT
774 template <class Tuple
>
775 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple
))
776 ConstField(const Tuple
& t
) { return t
.f1_
; }
782 template <class Tuple
>
783 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple
))
784 Field(Tuple
& t
) { return t
.f2_
; } // NOLINT
786 template <class Tuple
>
787 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple
))
788 ConstField(const Tuple
& t
) { return t
.f2_
; }
794 template <class Tuple
>
795 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple
))
796 Field(Tuple
& t
) { return t
.f3_
; } // NOLINT
798 template <class Tuple
>
799 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple
))
800 ConstField(const Tuple
& t
) { return t
.f3_
; }
806 template <class Tuple
>
807 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple
))
808 Field(Tuple
& t
) { return t
.f4_
; } // NOLINT
810 template <class Tuple
>
811 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple
))
812 ConstField(const Tuple
& t
) { return t
.f4_
; }
818 template <class Tuple
>
819 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple
))
820 Field(Tuple
& t
) { return t
.f5_
; } // NOLINT
822 template <class Tuple
>
823 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple
))
824 ConstField(const Tuple
& t
) { return t
.f5_
; }
830 template <class Tuple
>
831 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple
))
832 Field(Tuple
& t
) { return t
.f6_
; } // NOLINT
834 template <class Tuple
>
835 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple
))
836 ConstField(const Tuple
& t
) { return t
.f6_
; }
842 template <class Tuple
>
843 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple
))
844 Field(Tuple
& t
) { return t
.f7_
; } // NOLINT
846 template <class Tuple
>
847 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple
))
848 ConstField(const Tuple
& t
) { return t
.f7_
; }
854 template <class Tuple
>
855 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple
))
856 Field(Tuple
& t
) { return t
.f8_
; } // NOLINT
858 template <class Tuple
>
859 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple
))
860 ConstField(const Tuple
& t
) { return t
.f8_
; }
866 template <class Tuple
>
867 static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple
))
868 Field(Tuple
& t
) { return t
.f9_
; } // NOLINT
870 template <class Tuple
>
871 static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple
))
872 ConstField(const Tuple
& t
) { return t
.f9_
; }
875 } // namespace gtest_internal
877 template <int k
, GTEST_10_TYPENAMES_(T
)>
878 GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k
, GTEST_10_TUPLE_(T
)))
879 get(GTEST_10_TUPLE_(T
)& t
) {
880 return gtest_internal::Get
<k
>::Field(t
);
883 template <int k
, GTEST_10_TYPENAMES_(T
)>
884 GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k
, GTEST_10_TUPLE_(T
)))
885 get(const GTEST_10_TUPLE_(T
)& t
) {
886 return gtest_internal::Get
<k
>::ConstField(t
);
889 // 6.1.3.5 Relational operators
891 // We only implement == and !=, as we don't have a need for the rest yet.
893 namespace gtest_internal
{
895 // SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
896 // first k fields of t1 equals the first k fields of t2.
897 // SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
899 template <int kSize1
, int kSize2
>
900 struct SameSizeTuplePrefixComparator
;
903 struct SameSizeTuplePrefixComparator
<0, 0> {
904 template <class Tuple1
, class Tuple2
>
905 static bool Eq(const Tuple1
& /* t1 */, const Tuple2
& /* t2 */) {
911 struct SameSizeTuplePrefixComparator
<k
, k
> {
912 template <class Tuple1
, class Tuple2
>
913 static bool Eq(const Tuple1
& t1
, const Tuple2
& t2
) {
914 return SameSizeTuplePrefixComparator
<k
- 1, k
- 1>::Eq(t1
, t2
) &&
915 ::std::tr1::get
<k
- 1>(t1
) == ::std::tr1::get
<k
- 1>(t2
);
919 } // namespace gtest_internal
921 template <GTEST_10_TYPENAMES_(T
), GTEST_10_TYPENAMES_(U
)>
922 inline bool operator==(const GTEST_10_TUPLE_(T
)& t
,
923 const GTEST_10_TUPLE_(U
)& u
) {
924 return gtest_internal::SameSizeTuplePrefixComparator
<
925 tuple_size
<GTEST_10_TUPLE_(T
)>::value
,
926 tuple_size
<GTEST_10_TUPLE_(U
)>::value
>::Eq(t
, u
);
929 template <GTEST_10_TYPENAMES_(T
), GTEST_10_TYPENAMES_(U
)>
930 inline bool operator!=(const GTEST_10_TUPLE_(T
)& t
,
931 const GTEST_10_TUPLE_(U
)& u
) { return !(t
== u
); }
939 #undef GTEST_0_TUPLE_
940 #undef GTEST_1_TUPLE_
941 #undef GTEST_2_TUPLE_
942 #undef GTEST_3_TUPLE_
943 #undef GTEST_4_TUPLE_
944 #undef GTEST_5_TUPLE_
945 #undef GTEST_6_TUPLE_
946 #undef GTEST_7_TUPLE_
947 #undef GTEST_8_TUPLE_
948 #undef GTEST_9_TUPLE_
949 #undef GTEST_10_TUPLE_
951 #undef GTEST_0_TYPENAMES_
952 #undef GTEST_1_TYPENAMES_
953 #undef GTEST_2_TYPENAMES_
954 #undef GTEST_3_TYPENAMES_
955 #undef GTEST_4_TYPENAMES_
956 #undef GTEST_5_TYPENAMES_
957 #undef GTEST_6_TYPENAMES_
958 #undef GTEST_7_TYPENAMES_
959 #undef GTEST_8_TYPENAMES_
960 #undef GTEST_9_TYPENAMES_
961 #undef GTEST_10_TYPENAMES_
963 #undef GTEST_DECLARE_TUPLE_AS_FRIEND_
965 #undef GTEST_ADD_REF_
966 #undef GTEST_TUPLE_ELEMENT_
968 #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_