You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

968 lines
28 KiB

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