PageRenderTime 191ms CodeModel.GetById 41ms app.highlight 109ms RepoModel.GetById 31ms app.codeStats 1ms

/Unittests/googletest/include/gtest/internal/gtest-tuple.h

http://unladen-swallow.googlecode.com/
C++ Header | 966 lines | 705 code | 196 blank | 65 comment | 2 complexity | c01d6cf281d8c513606328274a6e9da9 MD5 | raw file
  1// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
  2
  3// Copyright 2009 Google Inc.
  4// All Rights Reserved.
  5//
  6// Redistribution and use in source and binary forms, with or without
  7// modification, are permitted provided that the following conditions are
  8// met:
  9//
 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
 15// distribution.
 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.
 19//
 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.
 31//
 32// Author: wan@google.com (Zhanyong Wan)
 33
 34// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
 35
 36#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
 37#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
 38
 39#include <utility>  // For ::std::pair.
 40
 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
 44// private as public.
 45#if defined(__SYMBIAN32__)
 46#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
 47#else
 48#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
 49    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
 50   private:
 51#endif
 52
 53// GTEST_n_TUPLE_(T) is the type of an n-tuple.
 54#define GTEST_0_TUPLE_(T) tuple<>
 55#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
 56    void, void, void>
 57#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
 58    void, void, void>
 59#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
 60    void, void, void>
 61#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
 62    void, void, void>
 63#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
 64    void, void, void>
 65#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
 66    void, void, void>
 67#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
 68    void, void, void>
 69#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
 70    T##7, void, void>
 71#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
 72    T##7, T##8, void>
 73#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
 74    T##7, T##8, T##9>
 75
 76// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
 77#define GTEST_0_TYPENAMES_(T)
 78#define GTEST_1_TYPENAMES_(T) typename T##0
 79#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
 80#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
 81#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 82    typename T##3
 83#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 84    typename T##3, typename T##4
 85#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 86    typename T##3, typename T##4, typename T##5
 87#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 88    typename T##3, typename T##4, typename T##5, typename T##6
 89#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 90    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
 91#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 92    typename T##3, typename T##4, typename T##5, typename T##6, \
 93    typename T##7, typename T##8
 94#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
 95    typename T##3, typename T##4, typename T##5, typename T##6, \
 96    typename T##7, typename T##8, typename T##9
 97
 98// In theory, defining stuff in the ::std namespace is undefined
 99// behavior.  We can do this as we are playing the role of a standard
100// library vendor.
101namespace std {
102namespace tr1 {
103
104template <typename T0 = void, typename T1 = void, typename T2 = void,
105    typename T3 = void, typename T4 = void, typename T5 = void,
106    typename T6 = void, typename T7 = void, typename T8 = void,
107    typename T9 = void>
108class tuple;
109
110// Anything in namespace gtest_internal is Google Test's INTERNAL
111// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
112namespace gtest_internal {
113
114// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
115template <typename T>
116struct ByRef { typedef const T& type; };  // NOLINT
117template <typename T>
118struct ByRef<T&> { typedef T& type; };  // NOLINT
119
120// A handy wrapper for ByRef.
121#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
122
123// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
124// is the same as tr1::add_reference<T>::type.
125template <typename T>
126struct AddRef { typedef T& type; };  // NOLINT
127template <typename T>
128struct AddRef<T&> { typedef T& type; };  // NOLINT
129
130// A handy wrapper for AddRef.
131#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
132
133// A helper for implementing get<k>().
134template <int k> class Get;
135
136// A helper for implementing tuple_element<k, T>.  kIndexValid is true
137// iff k < the number of fields in tuple type T.
138template <bool kIndexValid, int kIndex, class Tuple>
139struct TupleElement;
140
141template <GTEST_10_TYPENAMES_(T)>
142struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
143
144template <GTEST_10_TYPENAMES_(T)>
145struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
146
147template <GTEST_10_TYPENAMES_(T)>
148struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
149
150template <GTEST_10_TYPENAMES_(T)>
151struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
152
153template <GTEST_10_TYPENAMES_(T)>
154struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
155
156template <GTEST_10_TYPENAMES_(T)>
157struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
158
159template <GTEST_10_TYPENAMES_(T)>
160struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
161
162template <GTEST_10_TYPENAMES_(T)>
163struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
164
165template <GTEST_10_TYPENAMES_(T)>
166struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
167
168template <GTEST_10_TYPENAMES_(T)>
169struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
170
171}  // namespace gtest_internal
172
173template <>
174class tuple<> {
175 public:
176  tuple() {}
177  tuple(const tuple& /* t */)  {}
178  tuple& operator=(const tuple& /* t */) { return *this; }
179};
180
181template <GTEST_1_TYPENAMES_(T)>
182class GTEST_1_TUPLE_(T) {
183 public:
184  template <int k> friend class gtest_internal::Get;
185
186  tuple() {}
187
188  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
189
190  tuple(const tuple& t) : f0_(t.f0_) {}
191
192  template <GTEST_1_TYPENAMES_(U)>
193  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
194
195  tuple& operator=(const tuple& t) { return CopyFrom(t); }
196
197  template <GTEST_1_TYPENAMES_(U)>
198  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
199    return CopyFrom(t);
200  }
201
202  GTEST_DECLARE_TUPLE_AS_FRIEND_
203
204  template <GTEST_1_TYPENAMES_(U)>
205  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
206    f0_ = t.f0_;
207    return *this;
208  }
209
210  T0 f0_;
211};
212
213template <GTEST_2_TYPENAMES_(T)>
214class GTEST_2_TUPLE_(T) {
215 public:
216  template <int k> friend class gtest_internal::Get;
217
218  tuple() {}
219
220  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
221      f1_(f1) {}
222
223  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
224
225  template <GTEST_2_TYPENAMES_(U)>
226  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
227  template <typename U0, typename U1>
228  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
229
230  tuple& operator=(const tuple& t) { return CopyFrom(t); }
231
232  template <GTEST_2_TYPENAMES_(U)>
233  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
234    return CopyFrom(t);
235  }
236  template <typename U0, typename U1>
237  tuple& operator=(const ::std::pair<U0, U1>& p) {
238    f0_ = p.first;
239    f1_ = p.second;
240    return *this;
241  }
242
243  GTEST_DECLARE_TUPLE_AS_FRIEND_
244
245  template <GTEST_2_TYPENAMES_(U)>
246  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
247    f0_ = t.f0_;
248    f1_ = t.f1_;
249    return *this;
250  }
251
252  T0 f0_;
253  T1 f1_;
254};
255
256template <GTEST_3_TYPENAMES_(T)>
257class GTEST_3_TUPLE_(T) {
258 public:
259  template <int k> friend class gtest_internal::Get;
260
261  tuple() {}
262
263  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
264      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
265
266  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
267
268  template <GTEST_3_TYPENAMES_(U)>
269  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
270
271  tuple& operator=(const tuple& t) { return CopyFrom(t); }
272
273  template <GTEST_3_TYPENAMES_(U)>
274  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
275    return CopyFrom(t);
276  }
277
278  GTEST_DECLARE_TUPLE_AS_FRIEND_
279
280  template <GTEST_3_TYPENAMES_(U)>
281  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
282    f0_ = t.f0_;
283    f1_ = t.f1_;
284    f2_ = t.f2_;
285    return *this;
286  }
287
288  T0 f0_;
289  T1 f1_;
290  T2 f2_;
291};
292
293template <GTEST_4_TYPENAMES_(T)>
294class GTEST_4_TUPLE_(T) {
295 public:
296  template <int k> friend class gtest_internal::Get;
297
298  tuple() {}
299
300  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
301      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
302      f3_(f3) {}
303
304  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
305
306  template <GTEST_4_TYPENAMES_(U)>
307  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
308      f3_(t.f3_) {}
309
310  tuple& operator=(const tuple& t) { return CopyFrom(t); }
311
312  template <GTEST_4_TYPENAMES_(U)>
313  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
314    return CopyFrom(t);
315  }
316
317  GTEST_DECLARE_TUPLE_AS_FRIEND_
318
319  template <GTEST_4_TYPENAMES_(U)>
320  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
321    f0_ = t.f0_;
322    f1_ = t.f1_;
323    f2_ = t.f2_;
324    f3_ = t.f3_;
325    return *this;
326  }
327
328  T0 f0_;
329  T1 f1_;
330  T2 f2_;
331  T3 f3_;
332};
333
334template <GTEST_5_TYPENAMES_(T)>
335class GTEST_5_TUPLE_(T) {
336 public:
337  template <int k> friend class gtest_internal::Get;
338
339  tuple() {}
340
341  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
342      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
343      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
344
345  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
346      f4_(t.f4_) {}
347
348  template <GTEST_5_TYPENAMES_(U)>
349  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
350      f3_(t.f3_), f4_(t.f4_) {}
351
352  tuple& operator=(const tuple& t) { return CopyFrom(t); }
353
354  template <GTEST_5_TYPENAMES_(U)>
355  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
356    return CopyFrom(t);
357  }
358
359  GTEST_DECLARE_TUPLE_AS_FRIEND_
360
361  template <GTEST_5_TYPENAMES_(U)>
362  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
363    f0_ = t.f0_;
364    f1_ = t.f1_;
365    f2_ = t.f2_;
366    f3_ = t.f3_;
367    f4_ = t.f4_;
368    return *this;
369  }
370
371  T0 f0_;
372  T1 f1_;
373  T2 f2_;
374  T3 f3_;
375  T4 f4_;
376};
377
378template <GTEST_6_TYPENAMES_(T)>
379class GTEST_6_TUPLE_(T) {
380 public:
381  template <int k> friend class gtest_internal::Get;
382
383  tuple() {}
384
385  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
386      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
387      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
388      f5_(f5) {}
389
390  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
391      f4_(t.f4_), f5_(t.f5_) {}
392
393  template <GTEST_6_TYPENAMES_(U)>
394  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
395      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
396
397  tuple& operator=(const tuple& t) { return CopyFrom(t); }
398
399  template <GTEST_6_TYPENAMES_(U)>
400  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
401    return CopyFrom(t);
402  }
403
404  GTEST_DECLARE_TUPLE_AS_FRIEND_
405
406  template <GTEST_6_TYPENAMES_(U)>
407  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
408    f0_ = t.f0_;
409    f1_ = t.f1_;
410    f2_ = t.f2_;
411    f3_ = t.f3_;
412    f4_ = t.f4_;
413    f5_ = t.f5_;
414    return *this;
415  }
416
417  T0 f0_;
418  T1 f1_;
419  T2 f2_;
420  T3 f3_;
421  T4 f4_;
422  T5 f5_;
423};
424
425template <GTEST_7_TYPENAMES_(T)>
426class GTEST_7_TUPLE_(T) {
427 public:
428  template <int k> friend class gtest_internal::Get;
429
430  tuple() {}
431
432  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
433      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
434      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
435      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
436
437  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
438      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
439
440  template <GTEST_7_TYPENAMES_(U)>
441  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
442      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
443
444  tuple& operator=(const tuple& t) { return CopyFrom(t); }
445
446  template <GTEST_7_TYPENAMES_(U)>
447  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
448    return CopyFrom(t);
449  }
450
451  GTEST_DECLARE_TUPLE_AS_FRIEND_
452
453  template <GTEST_7_TYPENAMES_(U)>
454  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
455    f0_ = t.f0_;
456    f1_ = t.f1_;
457    f2_ = t.f2_;
458    f3_ = t.f3_;
459    f4_ = t.f4_;
460    f5_ = t.f5_;
461    f6_ = t.f6_;
462    return *this;
463  }
464
465  T0 f0_;
466  T1 f1_;
467  T2 f2_;
468  T3 f3_;
469  T4 f4_;
470  T5 f5_;
471  T6 f6_;
472};
473
474template <GTEST_8_TYPENAMES_(T)>
475class GTEST_8_TUPLE_(T) {
476 public:
477  template <int k> friend class gtest_internal::Get;
478
479  tuple() {}
480
481  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
482      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
483      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
484      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
485      f5_(f5), f6_(f6), f7_(f7) {}
486
487  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
488      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
489
490  template <GTEST_8_TYPENAMES_(U)>
491  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
492      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
493
494  tuple& operator=(const tuple& t) { return CopyFrom(t); }
495
496  template <GTEST_8_TYPENAMES_(U)>
497  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
498    return CopyFrom(t);
499  }
500
501  GTEST_DECLARE_TUPLE_AS_FRIEND_
502
503  template <GTEST_8_TYPENAMES_(U)>
504  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
505    f0_ = t.f0_;
506    f1_ = t.f1_;
507    f2_ = t.f2_;
508    f3_ = t.f3_;
509    f4_ = t.f4_;
510    f5_ = t.f5_;
511    f6_ = t.f6_;
512    f7_ = t.f7_;
513    return *this;
514  }
515
516  T0 f0_;
517  T1 f1_;
518  T2 f2_;
519  T3 f3_;
520  T4 f4_;
521  T5 f5_;
522  T6 f6_;
523  T7 f7_;
524};
525
526template <GTEST_9_TYPENAMES_(T)>
527class GTEST_9_TUPLE_(T) {
528 public:
529  template <int k> friend class gtest_internal::Get;
530
531  tuple() {}
532
533  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
534      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
535      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
536      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
537      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
538
539  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
540      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
541
542  template <GTEST_9_TYPENAMES_(U)>
543  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
544      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
545
546  tuple& operator=(const tuple& t) { return CopyFrom(t); }
547
548  template <GTEST_9_TYPENAMES_(U)>
549  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
550    return CopyFrom(t);
551  }
552
553  GTEST_DECLARE_TUPLE_AS_FRIEND_
554
555  template <GTEST_9_TYPENAMES_(U)>
556  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
557    f0_ = t.f0_;
558    f1_ = t.f1_;
559    f2_ = t.f2_;
560    f3_ = t.f3_;
561    f4_ = t.f4_;
562    f5_ = t.f5_;
563    f6_ = t.f6_;
564    f7_ = t.f7_;
565    f8_ = t.f8_;
566    return *this;
567  }
568
569  T0 f0_;
570  T1 f1_;
571  T2 f2_;
572  T3 f3_;
573  T4 f4_;
574  T5 f5_;
575  T6 f6_;
576  T7 f7_;
577  T8 f8_;
578};
579
580template <GTEST_10_TYPENAMES_(T)>
581class tuple {
582 public:
583  template <int k> friend class gtest_internal::Get;
584
585  tuple() {}
586
587  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
588      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
589      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
590      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
591      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
592
593  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
594      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
595
596  template <GTEST_10_TYPENAMES_(U)>
597  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
598      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
599      f9_(t.f9_) {}
600
601  tuple& operator=(const tuple& t) { return CopyFrom(t); }
602
603  template <GTEST_10_TYPENAMES_(U)>
604  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
605    return CopyFrom(t);
606  }
607
608  GTEST_DECLARE_TUPLE_AS_FRIEND_
609
610  template <GTEST_10_TYPENAMES_(U)>
611  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
612    f0_ = t.f0_;
613    f1_ = t.f1_;
614    f2_ = t.f2_;
615    f3_ = t.f3_;
616    f4_ = t.f4_;
617    f5_ = t.f5_;
618    f6_ = t.f6_;
619    f7_ = t.f7_;
620    f8_ = t.f8_;
621    f9_ = t.f9_;
622    return *this;
623  }
624
625  T0 f0_;
626  T1 f1_;
627  T2 f2_;
628  T3 f3_;
629  T4 f4_;
630  T5 f5_;
631  T6 f6_;
632  T7 f7_;
633  T8 f8_;
634  T9 f9_;
635};
636
637// 6.1.3.2 Tuple creation functions.
638
639// Known limitations: we don't support passing an
640// std::tr1::reference_wrapper<T> to make_tuple().  And we don't
641// implement tie().
642
643inline tuple<> make_tuple() { return tuple<>(); }
644
645template <GTEST_1_TYPENAMES_(T)>
646inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
647  return GTEST_1_TUPLE_(T)(f0);
648}
649
650template <GTEST_2_TYPENAMES_(T)>
651inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
652  return GTEST_2_TUPLE_(T)(f0, f1);
653}
654
655template <GTEST_3_TYPENAMES_(T)>
656inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
657  return GTEST_3_TUPLE_(T)(f0, f1, f2);
658}
659
660template <GTEST_4_TYPENAMES_(T)>
661inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
662    const T3& f3) {
663  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
664}
665
666template <GTEST_5_TYPENAMES_(T)>
667inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
668    const T3& f3, const T4& f4) {
669  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
670}
671
672template <GTEST_6_TYPENAMES_(T)>
673inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
674    const T3& f3, const T4& f4, const T5& f5) {
675  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
676}
677
678template <GTEST_7_TYPENAMES_(T)>
679inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
680    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
681  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
682}
683
684template <GTEST_8_TYPENAMES_(T)>
685inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
686    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
687  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
688}
689
690template <GTEST_9_TYPENAMES_(T)>
691inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
692    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
693    const T8& f8) {
694  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
695}
696
697template <GTEST_10_TYPENAMES_(T)>
698inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
699    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
700    const T8& f8, const T9& f9) {
701  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
702}
703
704// 6.1.3.3 Tuple helper classes.
705
706template <typename Tuple> struct tuple_size;
707
708template <GTEST_0_TYPENAMES_(T)>
709struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
710
711template <GTEST_1_TYPENAMES_(T)>
712struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
713
714template <GTEST_2_TYPENAMES_(T)>
715struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
716
717template <GTEST_3_TYPENAMES_(T)>
718struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
719
720template <GTEST_4_TYPENAMES_(T)>
721struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
722
723template <GTEST_5_TYPENAMES_(T)>
724struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
725
726template <GTEST_6_TYPENAMES_(T)>
727struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
728
729template <GTEST_7_TYPENAMES_(T)>
730struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
731
732template <GTEST_8_TYPENAMES_(T)>
733struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
734
735template <GTEST_9_TYPENAMES_(T)>
736struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
737
738template <GTEST_10_TYPENAMES_(T)>
739struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
740
741template <int k, class Tuple>
742struct tuple_element {
743  typedef typename gtest_internal::TupleElement<
744      k < (tuple_size<Tuple>::value), k, Tuple>::type type;
745};
746
747#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
748
749// 6.1.3.4 Element access.
750
751namespace gtest_internal {
752
753template <>
754class Get<0> {
755 public:
756  template <class Tuple>
757  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
758  Field(Tuple& t) { return t.f0_; }  // NOLINT
759
760  template <class Tuple>
761  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
762  ConstField(const Tuple& t) { return t.f0_; }
763};
764
765template <>
766class Get<1> {
767 public:
768  template <class Tuple>
769  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
770  Field(Tuple& t) { return t.f1_; }  // NOLINT
771
772  template <class Tuple>
773  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
774  ConstField(const Tuple& t) { return t.f1_; }
775};
776
777template <>
778class Get<2> {
779 public:
780  template <class Tuple>
781  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
782  Field(Tuple& t) { return t.f2_; }  // NOLINT
783
784  template <class Tuple>
785  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
786  ConstField(const Tuple& t) { return t.f2_; }
787};
788
789template <>
790class Get<3> {
791 public:
792  template <class Tuple>
793  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
794  Field(Tuple& t) { return t.f3_; }  // NOLINT
795
796  template <class Tuple>
797  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
798  ConstField(const Tuple& t) { return t.f3_; }
799};
800
801template <>
802class Get<4> {
803 public:
804  template <class Tuple>
805  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
806  Field(Tuple& t) { return t.f4_; }  // NOLINT
807
808  template <class Tuple>
809  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
810  ConstField(const Tuple& t) { return t.f4_; }
811};
812
813template <>
814class Get<5> {
815 public:
816  template <class Tuple>
817  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
818  Field(Tuple& t) { return t.f5_; }  // NOLINT
819
820  template <class Tuple>
821  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
822  ConstField(const Tuple& t) { return t.f5_; }
823};
824
825template <>
826class Get<6> {
827 public:
828  template <class Tuple>
829  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
830  Field(Tuple& t) { return t.f6_; }  // NOLINT
831
832  template <class Tuple>
833  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
834  ConstField(const Tuple& t) { return t.f6_; }
835};
836
837template <>
838class Get<7> {
839 public:
840  template <class Tuple>
841  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
842  Field(Tuple& t) { return t.f7_; }  // NOLINT
843
844  template <class Tuple>
845  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
846  ConstField(const Tuple& t) { return t.f7_; }
847};
848
849template <>
850class Get<8> {
851 public:
852  template <class Tuple>
853  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
854  Field(Tuple& t) { return t.f8_; }  // NOLINT
855
856  template <class Tuple>
857  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
858  ConstField(const Tuple& t) { return t.f8_; }
859};
860
861template <>
862class Get<9> {
863 public:
864  template <class Tuple>
865  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
866  Field(Tuple& t) { return t.f9_; }  // NOLINT
867
868  template <class Tuple>
869  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
870  ConstField(const Tuple& t) { return t.f9_; }
871};
872
873}  // namespace gtest_internal
874
875template <int k, GTEST_10_TYPENAMES_(T)>
876GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
877get(GTEST_10_TUPLE_(T)& t) {
878  return gtest_internal::Get<k>::Field(t);
879}
880
881template <int k, GTEST_10_TYPENAMES_(T)>
882GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))
883get(const GTEST_10_TUPLE_(T)& t) {
884  return gtest_internal::Get<k>::ConstField(t);
885}
886
887// 6.1.3.5 Relational operators
888
889// We only implement == and !=, as we don't have a need for the rest yet.
890
891namespace gtest_internal {
892
893// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
894// first k fields of t1 equals the first k fields of t2.
895// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
896// k1 != k2.
897template <int kSize1, int kSize2>
898struct SameSizeTuplePrefixComparator;
899
900template <>
901struct SameSizeTuplePrefixComparator<0, 0> {
902  template <class Tuple1, class Tuple2>
903  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
904    return true;
905  }
906};
907
908template <int k>
909struct SameSizeTuplePrefixComparator<k, k> {
910  template <class Tuple1, class Tuple2>
911  static bool Eq(const Tuple1& t1, const Tuple2& t2) {
912    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
913        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
914  }
915};
916
917}  // namespace gtest_internal
918
919template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
920inline bool operator==(const GTEST_10_TUPLE_(T)& t,
921                       const GTEST_10_TUPLE_(U)& u) {
922  return gtest_internal::SameSizeTuplePrefixComparator<
923      tuple_size<GTEST_10_TUPLE_(T)>::value,
924      tuple_size<GTEST_10_TUPLE_(U)>::value>::Eq(t, u);
925}
926
927template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
928inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
929                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
930
931// 6.1.4 Pairs.
932// Unimplemented.
933
934}  // namespace tr1
935}  // namespace std
936
937#undef GTEST_0_TUPLE_
938#undef GTEST_1_TUPLE_
939#undef GTEST_2_TUPLE_
940#undef GTEST_3_TUPLE_
941#undef GTEST_4_TUPLE_
942#undef GTEST_5_TUPLE_
943#undef GTEST_6_TUPLE_
944#undef GTEST_7_TUPLE_
945#undef GTEST_8_TUPLE_
946#undef GTEST_9_TUPLE_
947#undef GTEST_10_TUPLE_
948
949#undef GTEST_0_TYPENAMES_
950#undef GTEST_1_TYPENAMES_
951#undef GTEST_2_TYPENAMES_
952#undef GTEST_3_TYPENAMES_
953#undef GTEST_4_TYPENAMES_
954#undef GTEST_5_TYPENAMES_
955#undef GTEST_6_TYPENAMES_
956#undef GTEST_7_TYPENAMES_
957#undef GTEST_8_TYPENAMES_
958#undef GTEST_9_TYPENAMES_
959#undef GTEST_10_TYPENAMES_
960
961#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
962#undef GTEST_BY_REF_
963#undef GTEST_ADD_REF_
964#undef GTEST_TUPLE_ELEMENT_
965
966#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_