gtest-tuple.h 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  1. // This file was GENERATED by command:
  2. // pump.py gtest-tuple.h.pump
  3. // DO NOT EDIT BY HAND!!!
  4. // Copyright 2009 Google Inc.
  5. // All Rights Reserved.
  6. //
  7. // Redistribution and use in source and binary forms, with or without
  8. // modification, are permitted provided that the following conditions are
  9. // met:
  10. //
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Google Inc. nor the names of its
  18. // contributors may be used to endorse or promote products derived from
  19. // this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. // Author: wan@google.com (Zhanyong Wan)
  34. // Implements a subset of TR1 tuple needed by Google Test and Google Mock.
  35. #ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
  36. #define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
  37. #include <utility> // For ::std::pair.
  38. // The compiler used in Symbian has a bug that prevents us from declaring the
  39. // tuple template as a friend (it complains that tuple is redefined). This
  40. // hack bypasses the bug by declaring the members that should otherwise be
  41. // private as public.
  42. // Sun Studio versions < 12 also have the above bug.
  43. #if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
  44. # define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
  45. #else
  46. # define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
  47. template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
  48. private:
  49. #endif
  50. // GTEST_n_TUPLE_(T) is the type of an n-tuple.
  51. #define GTEST_0_TUPLE_(T) tuple<>
  52. #define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
  53. void, void, void>
  54. #define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
  55. void, void, void>
  56. #define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
  57. void, void, void>
  58. #define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
  59. void, void, void>
  60. #define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
  61. void, void, void>
  62. #define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
  63. void, void, void>
  64. #define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
  65. void, void, void>
  66. #define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
  67. T##7, void, void>
  68. #define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
  69. T##7, T##8, void>
  70. #define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
  71. T##7, T##8, T##9>
  72. // GTEST_n_TYPENAMES_(T) declares a list of n typenames.
  73. #define GTEST_0_TYPENAMES_(T)
  74. #define GTEST_1_TYPENAMES_(T) typename T##0
  75. #define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
  76. #define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
  77. #define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  78. typename T##3
  79. #define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  80. typename T##3, typename T##4
  81. #define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  82. typename T##3, typename T##4, typename T##5
  83. #define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  84. typename T##3, typename T##4, typename T##5, typename T##6
  85. #define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  86. typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
  87. #define GTEST_9_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. typename T##7, typename T##8
  90. #define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
  91. typename T##3, typename T##4, typename T##5, typename T##6, \
  92. typename T##7, typename T##8, typename T##9
  93. // In theory, defining stuff in the ::std namespace is undefined
  94. // behavior. We can do this as we are playing the role of a standard
  95. // library vendor.
  96. namespace std {
  97. namespace tr1 {
  98. template <typename T0 = void, typename T1 = void, typename T2 = void,
  99. typename T3 = void, typename T4 = void, typename T5 = void,
  100. typename T6 = void, typename T7 = void, typename T8 = void,
  101. typename T9 = void>
  102. class tuple;
  103. // Anything in namespace gtest_internal is Google Test's INTERNAL
  104. // IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
  105. namespace gtest_internal {
  106. // ByRef<T>::type is T if T is a reference; otherwise it's const T&.
  107. template <typename T>
  108. struct ByRef { typedef const T& type; }; // NOLINT
  109. template <typename T>
  110. struct ByRef<T&> { typedef T& type; }; // NOLINT
  111. // A handy wrapper for ByRef.
  112. #define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
  113. // AddRef<T>::type is T if T is a reference; otherwise it's T&. This
  114. // is the same as tr1::add_reference<T>::type.
  115. template <typename T>
  116. struct AddRef { typedef T& type; }; // NOLINT
  117. template <typename T>
  118. struct AddRef<T&> { typedef T& type; }; // NOLINT
  119. // A handy wrapper for AddRef.
  120. #define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
  121. // A helper for implementing get<k>().
  122. template <int k> class Get;
  123. // A helper for implementing tuple_element<k, T>. kIndexValid is true
  124. // iff k < the number of fields in tuple type T.
  125. template <bool kIndexValid, int kIndex, class Tuple>
  126. struct TupleElement;
  127. template <GTEST_10_TYPENAMES_(T)>
  128. struct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {
  129. typedef T0 type;
  130. };
  131. template <GTEST_10_TYPENAMES_(T)>
  132. struct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {
  133. typedef T1 type;
  134. };
  135. template <GTEST_10_TYPENAMES_(T)>
  136. struct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {
  137. typedef T2 type;
  138. };
  139. template <GTEST_10_TYPENAMES_(T)>
  140. struct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {
  141. typedef T3 type;
  142. };
  143. template <GTEST_10_TYPENAMES_(T)>
  144. struct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {
  145. typedef T4 type;
  146. };
  147. template <GTEST_10_TYPENAMES_(T)>
  148. struct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {
  149. typedef T5 type;
  150. };
  151. template <GTEST_10_TYPENAMES_(T)>
  152. struct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {
  153. typedef T6 type;
  154. };
  155. template <GTEST_10_TYPENAMES_(T)>
  156. struct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {
  157. typedef T7 type;
  158. };
  159. template <GTEST_10_TYPENAMES_(T)>
  160. struct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {
  161. typedef T8 type;
  162. };
  163. template <GTEST_10_TYPENAMES_(T)>
  164. struct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {
  165. typedef T9 type;
  166. };
  167. } // namespace gtest_internal
  168. template <>
  169. class tuple<> {
  170. public:
  171. tuple() {}
  172. tuple(const tuple& /* t */) {}
  173. tuple& operator=(const tuple& /* t */) { return *this; }
  174. };
  175. template <GTEST_1_TYPENAMES_(T)>
  176. class GTEST_1_TUPLE_(T) {
  177. public:
  178. template <int k> friend class gtest_internal::Get;
  179. tuple() : f0_() {}
  180. explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
  181. tuple(const tuple& t) : f0_(t.f0_) {}
  182. template <GTEST_1_TYPENAMES_(U)>
  183. tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
  184. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  185. template <GTEST_1_TYPENAMES_(U)>
  186. tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
  187. return CopyFrom(t);
  188. }
  189. GTEST_DECLARE_TUPLE_AS_FRIEND_
  190. template <GTEST_1_TYPENAMES_(U)>
  191. tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
  192. f0_ = t.f0_;
  193. return *this;
  194. }
  195. T0 f0_;
  196. };
  197. template <GTEST_2_TYPENAMES_(T)>
  198. class GTEST_2_TUPLE_(T) {
  199. public:
  200. template <int k> friend class gtest_internal::Get;
  201. tuple() : f0_(), f1_() {}
  202. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
  203. f1_(f1) {}
  204. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
  205. template <GTEST_2_TYPENAMES_(U)>
  206. tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
  207. template <typename U0, typename U1>
  208. tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
  209. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  210. template <GTEST_2_TYPENAMES_(U)>
  211. tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
  212. return CopyFrom(t);
  213. }
  214. template <typename U0, typename U1>
  215. tuple& operator=(const ::std::pair<U0, U1>& p) {
  216. f0_ = p.first;
  217. f1_ = p.second;
  218. return *this;
  219. }
  220. GTEST_DECLARE_TUPLE_AS_FRIEND_
  221. template <GTEST_2_TYPENAMES_(U)>
  222. tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
  223. f0_ = t.f0_;
  224. f1_ = t.f1_;
  225. return *this;
  226. }
  227. T0 f0_;
  228. T1 f1_;
  229. };
  230. template <GTEST_3_TYPENAMES_(T)>
  231. class GTEST_3_TUPLE_(T) {
  232. public:
  233. template <int k> friend class gtest_internal::Get;
  234. tuple() : f0_(), f1_(), f2_() {}
  235. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  236. GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
  237. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
  238. template <GTEST_3_TYPENAMES_(U)>
  239. tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
  240. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  241. template <GTEST_3_TYPENAMES_(U)>
  242. tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
  243. return CopyFrom(t);
  244. }
  245. GTEST_DECLARE_TUPLE_AS_FRIEND_
  246. template <GTEST_3_TYPENAMES_(U)>
  247. tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
  248. f0_ = t.f0_;
  249. f1_ = t.f1_;
  250. f2_ = t.f2_;
  251. return *this;
  252. }
  253. T0 f0_;
  254. T1 f1_;
  255. T2 f2_;
  256. };
  257. template <GTEST_4_TYPENAMES_(T)>
  258. class GTEST_4_TUPLE_(T) {
  259. public:
  260. template <int k> friend class gtest_internal::Get;
  261. tuple() : f0_(), f1_(), f2_(), f3_() {}
  262. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  263. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
  264. f3_(f3) {}
  265. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
  266. template <GTEST_4_TYPENAMES_(U)>
  267. tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  268. f3_(t.f3_) {}
  269. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  270. template <GTEST_4_TYPENAMES_(U)>
  271. tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
  272. return CopyFrom(t);
  273. }
  274. GTEST_DECLARE_TUPLE_AS_FRIEND_
  275. template <GTEST_4_TYPENAMES_(U)>
  276. tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
  277. f0_ = t.f0_;
  278. f1_ = t.f1_;
  279. f2_ = t.f2_;
  280. f3_ = t.f3_;
  281. return *this;
  282. }
  283. T0 f0_;
  284. T1 f1_;
  285. T2 f2_;
  286. T3 f3_;
  287. };
  288. template <GTEST_5_TYPENAMES_(T)>
  289. class GTEST_5_TUPLE_(T) {
  290. public:
  291. template <int k> friend class gtest_internal::Get;
  292. tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
  293. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  294. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
  295. GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
  296. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  297. f4_(t.f4_) {}
  298. template <GTEST_5_TYPENAMES_(U)>
  299. tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  300. f3_(t.f3_), f4_(t.f4_) {}
  301. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  302. template <GTEST_5_TYPENAMES_(U)>
  303. tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
  304. return CopyFrom(t);
  305. }
  306. GTEST_DECLARE_TUPLE_AS_FRIEND_
  307. template <GTEST_5_TYPENAMES_(U)>
  308. tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
  309. f0_ = t.f0_;
  310. f1_ = t.f1_;
  311. f2_ = t.f2_;
  312. f3_ = t.f3_;
  313. f4_ = t.f4_;
  314. return *this;
  315. }
  316. T0 f0_;
  317. T1 f1_;
  318. T2 f2_;
  319. T3 f3_;
  320. T4 f4_;
  321. };
  322. template <GTEST_6_TYPENAMES_(T)>
  323. class GTEST_6_TUPLE_(T) {
  324. public:
  325. template <int k> friend class gtest_internal::Get;
  326. tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
  327. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  328. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
  329. GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
  330. f5_(f5) {}
  331. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  332. f4_(t.f4_), f5_(t.f5_) {}
  333. template <GTEST_6_TYPENAMES_(U)>
  334. tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  335. f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
  336. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  337. template <GTEST_6_TYPENAMES_(U)>
  338. tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
  339. return CopyFrom(t);
  340. }
  341. GTEST_DECLARE_TUPLE_AS_FRIEND_
  342. template <GTEST_6_TYPENAMES_(U)>
  343. tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
  344. f0_ = t.f0_;
  345. f1_ = t.f1_;
  346. f2_ = t.f2_;
  347. f3_ = t.f3_;
  348. f4_ = t.f4_;
  349. f5_ = t.f5_;
  350. return *this;
  351. }
  352. T0 f0_;
  353. T1 f1_;
  354. T2 f2_;
  355. T3 f3_;
  356. T4 f4_;
  357. T5 f5_;
  358. };
  359. template <GTEST_7_TYPENAMES_(T)>
  360. class GTEST_7_TUPLE_(T) {
  361. public:
  362. template <int k> friend class gtest_internal::Get;
  363. tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
  364. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  365. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
  366. GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
  367. f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
  368. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  369. f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
  370. template <GTEST_7_TYPENAMES_(U)>
  371. tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  372. f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
  373. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  374. template <GTEST_7_TYPENAMES_(U)>
  375. tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
  376. return CopyFrom(t);
  377. }
  378. GTEST_DECLARE_TUPLE_AS_FRIEND_
  379. template <GTEST_7_TYPENAMES_(U)>
  380. tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
  381. f0_ = t.f0_;
  382. f1_ = t.f1_;
  383. f2_ = t.f2_;
  384. f3_ = t.f3_;
  385. f4_ = t.f4_;
  386. f5_ = t.f5_;
  387. f6_ = t.f6_;
  388. return *this;
  389. }
  390. T0 f0_;
  391. T1 f1_;
  392. T2 f2_;
  393. T3 f3_;
  394. T4 f4_;
  395. T5 f5_;
  396. T6 f6_;
  397. };
  398. template <GTEST_8_TYPENAMES_(T)>
  399. class GTEST_8_TUPLE_(T) {
  400. public:
  401. template <int k> friend class gtest_internal::Get;
  402. tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
  403. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  404. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
  405. GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
  406. GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
  407. f5_(f5), f6_(f6), f7_(f7) {}
  408. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  409. f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
  410. template <GTEST_8_TYPENAMES_(U)>
  411. tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  412. f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
  413. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  414. template <GTEST_8_TYPENAMES_(U)>
  415. tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
  416. return CopyFrom(t);
  417. }
  418. GTEST_DECLARE_TUPLE_AS_FRIEND_
  419. template <GTEST_8_TYPENAMES_(U)>
  420. tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
  421. f0_ = t.f0_;
  422. f1_ = t.f1_;
  423. f2_ = t.f2_;
  424. f3_ = t.f3_;
  425. f4_ = t.f4_;
  426. f5_ = t.f5_;
  427. f6_ = t.f6_;
  428. f7_ = t.f7_;
  429. return *this;
  430. }
  431. T0 f0_;
  432. T1 f1_;
  433. T2 f2_;
  434. T3 f3_;
  435. T4 f4_;
  436. T5 f5_;
  437. T6 f6_;
  438. T7 f7_;
  439. };
  440. template <GTEST_9_TYPENAMES_(T)>
  441. class GTEST_9_TUPLE_(T) {
  442. public:
  443. template <int k> friend class gtest_internal::Get;
  444. tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
  445. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  446. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
  447. GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
  448. GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
  449. f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
  450. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  451. f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
  452. template <GTEST_9_TYPENAMES_(U)>
  453. tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  454. f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
  455. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  456. template <GTEST_9_TYPENAMES_(U)>
  457. tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
  458. return CopyFrom(t);
  459. }
  460. GTEST_DECLARE_TUPLE_AS_FRIEND_
  461. template <GTEST_9_TYPENAMES_(U)>
  462. tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
  463. f0_ = t.f0_;
  464. f1_ = t.f1_;
  465. f2_ = t.f2_;
  466. f3_ = t.f3_;
  467. f4_ = t.f4_;
  468. f5_ = t.f5_;
  469. f6_ = t.f6_;
  470. f7_ = t.f7_;
  471. f8_ = t.f8_;
  472. return *this;
  473. }
  474. T0 f0_;
  475. T1 f1_;
  476. T2 f2_;
  477. T3 f3_;
  478. T4 f4_;
  479. T5 f5_;
  480. T6 f6_;
  481. T7 f7_;
  482. T8 f8_;
  483. };
  484. template <GTEST_10_TYPENAMES_(T)>
  485. class tuple {
  486. public:
  487. template <int k> friend class gtest_internal::Get;
  488. tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
  489. f9_() {}
  490. explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
  491. GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
  492. GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
  493. GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
  494. f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
  495. tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
  496. f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
  497. template <GTEST_10_TYPENAMES_(U)>
  498. tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
  499. f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
  500. f9_(t.f9_) {}
  501. tuple& operator=(const tuple& t) { return CopyFrom(t); }
  502. template <GTEST_10_TYPENAMES_(U)>
  503. tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
  504. return CopyFrom(t);
  505. }
  506. GTEST_DECLARE_TUPLE_AS_FRIEND_
  507. template <GTEST_10_TYPENAMES_(U)>
  508. tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
  509. f0_ = t.f0_;
  510. f1_ = t.f1_;
  511. f2_ = t.f2_;
  512. f3_ = t.f3_;
  513. f4_ = t.f4_;
  514. f5_ = t.f5_;
  515. f6_ = t.f6_;
  516. f7_ = t.f7_;
  517. f8_ = t.f8_;
  518. f9_ = t.f9_;
  519. return *this;
  520. }
  521. T0 f0_;
  522. T1 f1_;
  523. T2 f2_;
  524. T3 f3_;
  525. T4 f4_;
  526. T5 f5_;
  527. T6 f6_;
  528. T7 f7_;
  529. T8 f8_;
  530. T9 f9_;
  531. };
  532. // 6.1.3.2 Tuple creation functions.
  533. // Known limitations: we don't support passing an
  534. // std::tr1::reference_wrapper<T> to make_tuple(). And we don't
  535. // implement tie().
  536. inline tuple<> make_tuple() { return tuple<>(); }
  537. template <GTEST_1_TYPENAMES_(T)>
  538. inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
  539. return GTEST_1_TUPLE_(T)(f0);
  540. }
  541. template <GTEST_2_TYPENAMES_(T)>
  542. inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
  543. return GTEST_2_TUPLE_(T)(f0, f1);
  544. }
  545. template <GTEST_3_TYPENAMES_(T)>
  546. inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
  547. return GTEST_3_TUPLE_(T)(f0, f1, f2);
  548. }
  549. template <GTEST_4_TYPENAMES_(T)>
  550. inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  551. const T3& f3) {
  552. return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
  553. }
  554. template <GTEST_5_TYPENAMES_(T)>
  555. inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  556. const T3& f3, const T4& f4) {
  557. return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
  558. }
  559. template <GTEST_6_TYPENAMES_(T)>
  560. inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  561. const T3& f3, const T4& f4, const T5& f5) {
  562. return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
  563. }
  564. template <GTEST_7_TYPENAMES_(T)>
  565. inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  566. const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
  567. return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
  568. }
  569. template <GTEST_8_TYPENAMES_(T)>
  570. inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  571. const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
  572. return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
  573. }
  574. template <GTEST_9_TYPENAMES_(T)>
  575. inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  576. const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
  577. const T8& f8) {
  578. return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
  579. }
  580. template <GTEST_10_TYPENAMES_(T)>
  581. inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
  582. const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
  583. const T8& f8, const T9& f9) {
  584. return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
  585. }
  586. // 6.1.3.3 Tuple helper classes.
  587. template <typename Tuple> struct tuple_size;
  588. template <GTEST_0_TYPENAMES_(T)>
  589. struct tuple_size<GTEST_0_TUPLE_(T) > {
  590. static const int value = 0;
  591. };
  592. template <GTEST_1_TYPENAMES_(T)>
  593. struct tuple_size<GTEST_1_TUPLE_(T) > {
  594. static const int value = 1;
  595. };
  596. template <GTEST_2_TYPENAMES_(T)>
  597. struct tuple_size<GTEST_2_TUPLE_(T) > {
  598. static const int value = 2;
  599. };
  600. template <GTEST_3_TYPENAMES_(T)>
  601. struct tuple_size<GTEST_3_TUPLE_(T) > {
  602. static const int value = 3;
  603. };
  604. template <GTEST_4_TYPENAMES_(T)>
  605. struct tuple_size<GTEST_4_TUPLE_(T) > {
  606. static const int value = 4;
  607. };
  608. template <GTEST_5_TYPENAMES_(T)>
  609. struct tuple_size<GTEST_5_TUPLE_(T) > {
  610. static const int value = 5;
  611. };
  612. template <GTEST_6_TYPENAMES_(T)>
  613. struct tuple_size<GTEST_6_TUPLE_(T) > {
  614. static const int value = 6;
  615. };
  616. template <GTEST_7_TYPENAMES_(T)>
  617. struct tuple_size<GTEST_7_TUPLE_(T) > {
  618. static const int value = 7;
  619. };
  620. template <GTEST_8_TYPENAMES_(T)>
  621. struct tuple_size<GTEST_8_TUPLE_(T) > {
  622. static const int value = 8;
  623. };
  624. template <GTEST_9_TYPENAMES_(T)>
  625. struct tuple_size<GTEST_9_TUPLE_(T) > {
  626. static const int value = 9;
  627. };
  628. template <GTEST_10_TYPENAMES_(T)>
  629. struct tuple_size<GTEST_10_TUPLE_(T) > {
  630. static const int value = 10;
  631. };
  632. template <int k, class Tuple>
  633. struct tuple_element {
  634. typedef typename gtest_internal::TupleElement<
  635. k < (tuple_size<Tuple>::value), k, Tuple>::type type;
  636. };
  637. #define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
  638. // 6.1.3.4 Element access.
  639. namespace gtest_internal {
  640. template <>
  641. class Get<0> {
  642. public:
  643. template <class Tuple>
  644. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
  645. Field(Tuple& t) { return t.f0_; } // NOLINT
  646. template <class Tuple>
  647. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
  648. ConstField(const Tuple& t) { return t.f0_; }
  649. };
  650. template <>
  651. class Get<1> {
  652. public:
  653. template <class Tuple>
  654. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
  655. Field(Tuple& t) { return t.f1_; } // NOLINT
  656. template <class Tuple>
  657. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
  658. ConstField(const Tuple& t) { return t.f1_; }
  659. };
  660. template <>
  661. class Get<2> {
  662. public:
  663. template <class Tuple>
  664. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
  665. Field(Tuple& t) { return t.f2_; } // NOLINT
  666. template <class Tuple>
  667. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
  668. ConstField(const Tuple& t) { return t.f2_; }
  669. };
  670. template <>
  671. class Get<3> {
  672. public:
  673. template <class Tuple>
  674. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
  675. Field(Tuple& t) { return t.f3_; } // NOLINT
  676. template <class Tuple>
  677. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
  678. ConstField(const Tuple& t) { return t.f3_; }
  679. };
  680. template <>
  681. class Get<4> {
  682. public:
  683. template <class Tuple>
  684. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
  685. Field(Tuple& t) { return t.f4_; } // NOLINT
  686. template <class Tuple>
  687. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
  688. ConstField(const Tuple& t) { return t.f4_; }
  689. };
  690. template <>
  691. class Get<5> {
  692. public:
  693. template <class Tuple>
  694. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
  695. Field(Tuple& t) { return t.f5_; } // NOLINT
  696. template <class Tuple>
  697. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
  698. ConstField(const Tuple& t) { return t.f5_; }
  699. };
  700. template <>
  701. class Get<6> {
  702. public:
  703. template <class Tuple>
  704. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
  705. Field(Tuple& t) { return t.f6_; } // NOLINT
  706. template <class Tuple>
  707. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
  708. ConstField(const Tuple& t) { return t.f6_; }
  709. };
  710. template <>
  711. class Get<7> {
  712. public:
  713. template <class Tuple>
  714. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
  715. Field(Tuple& t) { return t.f7_; } // NOLINT
  716. template <class Tuple>
  717. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
  718. ConstField(const Tuple& t) { return t.f7_; }
  719. };
  720. template <>
  721. class Get<8> {
  722. public:
  723. template <class Tuple>
  724. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
  725. Field(Tuple& t) { return t.f8_; } // NOLINT
  726. template <class Tuple>
  727. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
  728. ConstField(const Tuple& t) { return t.f8_; }
  729. };
  730. template <>
  731. class Get<9> {
  732. public:
  733. template <class Tuple>
  734. static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
  735. Field(Tuple& t) { return t.f9_; } // NOLINT
  736. template <class Tuple>
  737. static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
  738. ConstField(const Tuple& t) { return t.f9_; }
  739. };
  740. } // namespace gtest_internal
  741. template <int k, GTEST_10_TYPENAMES_(T)>
  742. GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
  743. get(GTEST_10_TUPLE_(T)& t) {
  744. return gtest_internal::Get<k>::Field(t);
  745. }
  746. template <int k, GTEST_10_TYPENAMES_(T)>
  747. GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
  748. get(const GTEST_10_TUPLE_(T)& t) {
  749. return gtest_internal::Get<k>::ConstField(t);
  750. }
  751. // 6.1.3.5 Relational operators
  752. // We only implement == and !=, as we don't have a need for the rest yet.
  753. namespace gtest_internal {
  754. // SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
  755. // first k fields of t1 equals the first k fields of t2.
  756. // SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
  757. // k1 != k2.
  758. template <int kSize1, int kSize2>
  759. struct SameSizeTuplePrefixComparator;
  760. template <>
  761. struct SameSizeTuplePrefixComparator<0, 0> {
  762. template <class Tuple1, class Tuple2>
  763. static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
  764. return true;
  765. }
  766. };
  767. template <int k>
  768. struct SameSizeTuplePrefixComparator<k, k> {
  769. template <class Tuple1, class Tuple2>
  770. static bool Eq(const Tuple1& t1, const Tuple2& t2) {
  771. return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
  772. ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
  773. }
  774. };
  775. } // namespace gtest_internal
  776. template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
  777. inline bool operator==(const GTEST_10_TUPLE_(T)& t,
  778. const GTEST_10_TUPLE_(U)& u) {
  779. return gtest_internal::SameSizeTuplePrefixComparator<
  780. tuple_size<GTEST_10_TUPLE_(T) >::value,
  781. tuple_size<GTEST_10_TUPLE_(U) >::value>::Eq(t, u);
  782. }
  783. template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
  784. inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
  785. const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
  786. // 6.1.4 Pairs.
  787. // Unimplemented.
  788. } // namespace tr1
  789. } // namespace std
  790. #undef GTEST_0_TUPLE_
  791. #undef GTEST_1_TUPLE_
  792. #undef GTEST_2_TUPLE_
  793. #undef GTEST_3_TUPLE_
  794. #undef GTEST_4_TUPLE_
  795. #undef GTEST_5_TUPLE_
  796. #undef GTEST_6_TUPLE_
  797. #undef GTEST_7_TUPLE_
  798. #undef GTEST_8_TUPLE_
  799. #undef GTEST_9_TUPLE_
  800. #undef GTEST_10_TUPLE_
  801. #undef GTEST_0_TYPENAMES_
  802. #undef GTEST_1_TYPENAMES_
  803. #undef GTEST_2_TYPENAMES_
  804. #undef GTEST_3_TYPENAMES_
  805. #undef GTEST_4_TYPENAMES_
  806. #undef GTEST_5_TYPENAMES_
  807. #undef GTEST_6_TYPENAMES_
  808. #undef GTEST_7_TYPENAMES_
  809. #undef GTEST_8_TYPENAMES_
  810. #undef GTEST_9_TYPENAMES_
  811. #undef GTEST_10_TYPENAMES_
  812. #undef GTEST_DECLARE_TUPLE_AS_FRIEND_
  813. #undef GTEST_BY_REF_
  814. #undef GTEST_ADD_REF_
  815. #undef GTEST_TUPLE_ELEMENT_
  816. #endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_