gtest-tuple.h 28 KB

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