gtest-tuple.h 28 KB

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