1// Copyright 2005, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8//     * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10//     * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14//     * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29//
30// Author: wan@google.com (Zhanyong Wan)
31//
32// The Google C++ Testing Framework (Google Test)
33//
34// This header file defines the public API for Google Test.  It should be
35// included by any test program that uses Google Test.
36//
37// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
38// leave some internal implementation details in this header file.
39// They are clearly marked by comments like this:
40//
41//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
42//
43// Such code is NOT meant to be used by a user directly, and is subject
44// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user
45// program!
46//
47// Acknowledgment: Google Test borrowed the idea of automatic test
48// registration from Barthelemy Dagenais' (barthelemy@prologique.com)
49// easyUnit framework.
50//
51/*****
52 * NAME
53 *
54 *
55 * AUTHOR
56 *   google
57 *
58 * COPYRIGHT
59 *   Copyright (c) 2004-2011 by cisco Systems, Inc.
60 *   All rights reserved.
61 *
62 * DESCRIPTION
63 *
64 ****/
65
66
67#ifndef GTEST_INCLUDE_GTEST_GTEST_H_
68#define GTEST_INCLUDE_GTEST_GTEST_H_
69
70#include <limits>
71#include <vector>
72
73// Copyright 2005, Google Inc.
74// All rights reserved.
75//
76// Redistribution and use in source and binary forms, with or without
77// modification, are permitted provided that the following conditions are
78// met:
79//
80//     * Redistributions of source code must retain the above copyright
81// notice, this list of conditions and the following disclaimer.
82//     * Redistributions in binary form must reproduce the above
83// copyright notice, this list of conditions and the following disclaimer
84// in the documentation and/or other materials provided with the
85// distribution.
86//     * Neither the name of Google Inc. nor the names of its
87// contributors may be used to endorse or promote products derived from
88// this software without specific prior written permission.
89//
90// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
91// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
92// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
93// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
94// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
95// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
96// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
97// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
98// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
99// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
100// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
101//
102// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
103//
104// The Google C++ Testing Framework (Google Test)
105//
106// This header file declares functions and macros used internally by
107// Google Test.  They are subject to change without notice.
108
109#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
110#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_
111
112// Copyright 2005, Google Inc.
113// All rights reserved.
114//
115// Redistribution and use in source and binary forms, with or without
116// modification, are permitted provided that the following conditions are
117// met:
118//
119//     * Redistributions of source code must retain the above copyright
120// notice, this list of conditions and the following disclaimer.
121//     * Redistributions in binary form must reproduce the above
122// copyright notice, this list of conditions and the following disclaimer
123// in the documentation and/or other materials provided with the
124// distribution.
125//     * Neither the name of Google Inc. nor the names of its
126// contributors may be used to endorse or promote products derived from
127// this software without specific prior written permission.
128//
129// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
130// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
131// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
132// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
133// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
134// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
135// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
136// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
137// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
138// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
139// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
140//
141// Authors: wan@google.com (Zhanyong Wan)
142//
143// Low-level types and utilities for porting Google Test to various
144// platforms.  They are subject to change without notice.  DO NOT USE
145// THEM IN USER CODE.
146
147#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
148#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
149
150// The user can define the following macros in the build script to
151// control Google Test's behavior.  If the user doesn't define a macro
152// in this list, Google Test will define it.
153//
154//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)
155//                              is/isn't available.
156//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions
157//                              are enabled.
158//   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string
159//                              is/isn't available (some systems define
160//                              ::string, which is different to std::string).
161//   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string
162//                              is/isn't available (some systems define
163//                              ::wstring, which is different to std::wstring).
164//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>
165//                              is/isn't available.
166//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't
167//                              enabled.
168//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that
169//                              std::wstring does/doesn't work (Google Test can
170//                              be used where std::wstring is unavailable).
171//   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple
172//                              is/isn't available.
173//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the
174//                              compiler supports Microsoft's "Structured
175//                              Exception Handling".
176//   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google
177//                              Test's own tr1 tuple implementation should be
178//                              used.  Unused when the user sets
179//                              GTEST_HAS_TR1_TUPLE to 0.
180//   GTEST_LINKED_AS_SHARED_LIBRARY
181//                            - Define to 1 when compiling tests that use
182//                              Google Test as a shared library (known as
183//                              DLL on Windows).
184//   GTEST_CREATE_SHARED_LIBRARY
185//                            - Define to 1 when compiling Google Test itself
186//                              as a shared library.
187
188// This header defines the following utilities:
189//
190// Macros indicating the current platform (defined to 1 if compiled on
191// the given platform; otherwise undefined):
192//   GTEST_OS_AIX      - IBM AIX
193//   GTEST_OS_CYGWIN   - Cygwin
194//   GTEST_OS_LINUX    - Linux
195//   GTEST_OS_MAC      - Mac OS X
196//   GTEST_OS_SOLARIS  - Sun Solaris
197//   GTEST_OS_SYMBIAN  - Symbian
198//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)
199//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop
200//     GTEST_OS_WINDOWS_MINGW    - MinGW
201//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile
202//   GTEST_OS_ZOS      - z/OS
203//
204// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the
205// most stable support.  Since core members of the Google Test project
206// don't have access to other platforms, support for them may be less
207// stable.  If you notice any problems on your platform, please notify
208// googletestframework@googlegroups.com (patches for fixing them are
209// even more welcome!).
210//
211// Note that it is possible that none of the GTEST_OS_* macros are defined.
212//
213// Macros indicating available Google Test features (defined to 1 if
214// the corresponding feature is supported; otherwise undefined):
215//   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized
216//                            tests)
217//   GTEST_HAS_DEATH_TEST   - death tests
218//   GTEST_HAS_PARAM_TEST   - value-parameterized tests
219//   GTEST_HAS_TYPED_TEST   - typed tests
220//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests
221//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used.
222//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;
223//                            the above two are mutually exclusive.
224//   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().
225//
226// Macros for basic C++ coding:
227//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.
228//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a
229//                              variable don't have to be used.
230//   GTEST_DISALLOW_ASSIGN_   - disables operator=.
231//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
232//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.
233//
234// Synchronization:
235//   Mutex, MutexLock, ThreadLocal, GetThreadCount()
236//                  - synchronization primitives.
237//   GTEST_IS_THREADSAFE - defined to 1 to indicate that the above
238//                         synchronization primitives have real implementations
239//                         and Google Test is thread-safe; or 0 otherwise.
240//
241// Template meta programming:
242//   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.
243//
244// Smart pointers:
245//   scoped_ptr     - as in TR2.
246//
247// Regular expressions:
248//   RE             - a simple regular expression class using the POSIX
249//                    Extended Regular Expression syntax.  Not available on
250//                    Windows.
251//
252// Logging:
253//   GTEST_LOG_()   - logs messages at the specified severity level.
254//   LogToStderr()  - directs all log messages to stderr.
255//   FlushInfoLog() - flushes informational log messages.
256//
257// Stdout and stderr capturing:
258//   CaptureStdout()     - starts capturing stdout.
259//   GetCapturedStdout() - stops capturing stdout and returns the captured
260//                         string.
261//   CaptureStderr()     - starts capturing stderr.
262//   GetCapturedStderr() - stops capturing stderr and returns the captured
263//                         string.
264//
265// Integer types:
266//   TypeWithSize   - maps an integer to a int type.
267//   Int32, UInt32, Int64, UInt64, TimeInMillis
268//                  - integers of known sizes.
269//   BiggestInt     - the biggest signed integer type.
270//
271// Command-line utilities:
272//   GTEST_FLAG()       - references a flag.
273//   GTEST_DECLARE_*()  - declares a flag.
274//   GTEST_DEFINE_*()   - defines a flag.
275//   GetArgvs()         - returns the command line as a vector of strings.
276//
277// Environment variable utilities:
278//   GetEnv()             - gets the value of an environment variable.
279//   BoolFromGTestEnv()   - parses a bool environment variable.
280//   Int32FromGTestEnv()  - parses an Int32 environment variable.
281//   StringFromGTestEnv() - parses a string environment variable.
282
283#include <stddef.h>  // For ptrdiff_t
284#include <stdlib.h>
285#include <stdio.h>
286#include <string.h>
287#ifndef _WIN32_WCE
288#include <sys/stat.h>
289#endif  // !_WIN32_WCE
290
291#include <iostream>  // NOLINT
292#include <sstream>  // NOLINT
293#include <string>  // NOLINT
294
295#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
296#define GTEST_FLAG_PREFIX_ "gtest_"
297#define GTEST_FLAG_PREFIX_DASH_ "gtest-"
298#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_"
299#define GTEST_NAME_ "Google Test"
300#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/"
301
302// Determines the version of gcc that is used to compile this.
303#ifdef __GNUC__
304// 40302 means version 4.3.2.
305#define GTEST_GCC_VER_ \
306    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
307#endif  // __GNUC__
308
309// Determines the platform on which Google Test is compiled.
310#ifdef __CYGWIN__
311#define GTEST_OS_CYGWIN 1
312#elif defined __SYMBIAN32__
313#define GTEST_OS_SYMBIAN 1
314#elif defined _WIN32
315#define GTEST_OS_WINDOWS 1
316#ifdef _WIN32_WCE
317#define GTEST_OS_WINDOWS_MOBILE 1
318#elif defined(__MINGW__) || defined(__MINGW32__)
319#define GTEST_OS_WINDOWS_MINGW 1
320#else
321#define GTEST_OS_WINDOWS_DESKTOP 1
322#endif  // _WIN32_WCE
323#elif defined __APPLE__
324#define GTEST_OS_MAC 1
325#elif defined __linux__
326#define GTEST_OS_LINUX 1
327#elif defined __MVS__
328#define GTEST_OS_ZOS 1
329#elif defined(__sun) && defined(__SVR4)
330#define GTEST_OS_SOLARIS 1
331#elif defined(_AIX)
332#define GTEST_OS_AIX 1
333#endif  // __CYGWIN__
334
335#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_SYMBIAN || \
336    GTEST_OS_SOLARIS || GTEST_OS_AIX
337
338// On some platforms, <regex.h> needs someone to define size_t, and
339// won't compile otherwise.  We can #include it here as we already
340// included <stdlib.h>, which is guaranteed to define size_t through
341// <stddef.h>.
342#include <regex.h>  // NOLINT
343#include <strings.h>  // NOLINT
344#include <sys/types.h>  // NOLINT
345#include <time.h>  // NOLINT
346#include <unistd.h>  // NOLINT
347
348#define GTEST_USES_POSIX_RE 1
349
350#elif GTEST_OS_WINDOWS
351
352#if !GTEST_OS_WINDOWS_MOBILE
353#include <direct.h>  // NOLINT
354#include <io.h>  // NOLINT
355#endif
356
357// <regex.h> is not available on Windows.  Use our own simple regex
358// implementation instead.
359#define GTEST_USES_SIMPLE_RE 1
360
361#else
362
363// <regex.h> may not be available on this platform.  Use our own
364// simple regex implementation instead.
365#define GTEST_USES_SIMPLE_RE 1
366
367#endif  // GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC ||
368        // GTEST_OS_SYMBIAN || GTEST_OS_SOLARIS || GTEST_OS_AIX
369
370#ifndef GTEST_HAS_EXCEPTIONS
371// The user didn't tell us whether exceptions are enabled, so we need
372// to figure it out.
373#if defined(_MSC_VER) || defined(__BORLANDC__)
374// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS
375// macro to enable exceptions, so we'll do the same.
376// Assumes that exceptions are enabled by default.
377#ifndef _HAS_EXCEPTIONS
378#define _HAS_EXCEPTIONS 1
379#endif  // _HAS_EXCEPTIONS
380#define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS
381#elif defined(__GNUC__) && __EXCEPTIONS
382// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.
383#define GTEST_HAS_EXCEPTIONS 1
384#elif defined(__SUNPRO_CC)
385// Sun Pro CC supports exceptions.  However, there is no compile-time way of
386// detecting whether they are enabled or not.  Therefore, we assume that
387// they are enabled unless the user tells us otherwise.
388#define GTEST_HAS_EXCEPTIONS 1
389#elif defined(__IBMCPP__) && __EXCEPTIONS
390// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.
391#define GTEST_HAS_EXCEPTIONS 1
392#else
393// For other compilers, we assume exceptions are disabled to be
394// conservative.
395#define GTEST_HAS_EXCEPTIONS 0
396#endif  // defined(_MSC_VER) || defined(__BORLANDC__)
397#endif  // GTEST_HAS_EXCEPTIONS
398
399#if !defined(GTEST_HAS_STD_STRING)
400// Even though we don't use this macro any longer, we keep it in case
401// some clients still depend on it.
402
403#if !defined OCTEON_BUILD
404#define GTEST_HAS_STD_STRING 1
405#endif
406
407
408#elif !GTEST_HAS_STD_STRING
409// The user told us that ::std::string isn't available.
410#error "Google Test cannot be used where ::std::string isn't available."
411#endif  // !defined(GTEST_HAS_STD_STRING)
412
413#ifndef GTEST_HAS_GLOBAL_STRING
414// The user didn't tell us whether ::string is available, so we need
415// to figure it out.
416
417#define GTEST_HAS_GLOBAL_STRING 0
418
419#endif  // GTEST_HAS_GLOBAL_STRING
420
421#ifndef GTEST_HAS_STD_WSTRING
422// The user didn't tell us whether ::std::wstring is available, so we need
423// to figure it out.
424// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring
425//   is available.
426
427// Cygwin 1.5 and below doesn't support ::std::wstring.
428// Cygwin 1.7 might add wstring support; this should be updated when clear.
429// Solaris' libc++ doesn't support it either.
430
431#if !defined OCTEON_BUILD
432#define GTEST_HAS_STD_WSTRING (!(GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))
433#endif
434
435#endif  // GTEST_HAS_STD_WSTRING
436
437#ifndef GTEST_HAS_GLOBAL_WSTRING
438// The user didn't tell us whether ::wstring is available, so we need
439// to figure it out.
440#define GTEST_HAS_GLOBAL_WSTRING \
441    (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)
442#endif  // GTEST_HAS_GLOBAL_WSTRING
443
444// Determines whether RTTI is available.
445#ifndef GTEST_HAS_RTTI
446// The user didn't tell us whether RTTI is enabled, so we need to
447// figure it out.
448
449#ifdef _MSC_VER
450
451#ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.
452#define GTEST_HAS_RTTI 1
453#else
454#define GTEST_HAS_RTTI 0
455#endif
456
457// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.
458#elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)
459
460#ifdef __GXX_RTTI
461#define GTEST_HAS_RTTI 1
462#else
463#define GTEST_HAS_RTTI 0
464#endif  // __GXX_RTTI
465
466// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if
467// both the typeid and dynamic_cast features are present.
468#elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)
469
470#ifdef __RTTI_ALL__
471#define GTEST_HAS_RTTI 1
472#else
473#define GTEST_HAS_RTTI 0
474#endif
475
476#else
477
478// For all other compilers, we assume RTTI is enabled.
479#define GTEST_HAS_RTTI 1
480
481#endif  // _MSC_VER
482
483#endif  // GTEST_HAS_RTTI
484
485// It's this header's responsibility to #include <typeinfo> when RTTI
486// is enabled.
487#if GTEST_HAS_RTTI
488#include <typeinfo>
489#endif
490
491// Determines whether Google Test can use the pthreads library.
492#ifndef GTEST_HAS_PTHREAD
493// The user didn't tell us explicitly, so we assume pthreads support is
494// available on Linux and Mac.
495//
496// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
497// to your compiler flags.
498#define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC)
499#endif  // GTEST_HAS_PTHREAD
500
501// Determines whether Google Test can use tr1/tuple.  You can define
502// this macro to 0 to prevent Google Test from using tuple (any
503// feature depending on tuple with be disabled in this mode).
504#ifndef GTEST_HAS_TR1_TUPLE
505// The user didn't tell us not to do it, so we assume it's OK.
506#define GTEST_HAS_TR1_TUPLE 1
507#endif  // GTEST_HAS_TR1_TUPLE
508
509// Determines whether Google Test's own tr1 tuple implementation
510// should be used.
511#ifndef GTEST_USE_OWN_TR1_TUPLE
512// The user didn't tell us, so we need to figure it out.
513
514// We use our own TR1 tuple if we aren't sure the user has an
515// implementation of it already.  At this time, GCC 4.0.0+ and MSVC
516// 2010 are the only mainstream compilers that come with a TR1 tuple
517// implementation.  NVIDIA's CUDA NVCC compiler pretends to be GCC by
518// defining __GNUC__ and friends, but cannot compile GCC's tuple
519// implementation.  MSVC 2008 (9.0) provides TR1 tuple in a 323 MB
520// Feature Pack download, which we cannot assume the user has.
521#if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000)) \
522    || _MSC_VER >= 1600
523#define GTEST_USE_OWN_TR1_TUPLE 0
524#else
525#define GTEST_USE_OWN_TR1_TUPLE 1
526#endif
527
528#endif  // GTEST_USE_OWN_TR1_TUPLE
529
530// To avoid conditional compilation everywhere, we make it
531// gtest-port.h's responsibility to #include the header implementing
532// tr1/tuple.
533#if GTEST_HAS_TR1_TUPLE
534
535#if GTEST_USE_OWN_TR1_TUPLE
536// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!
537
538// Copyright 2009 Google Inc.
539// All Rights Reserved.
540//
541// Redistribution and use in source and binary forms, with or without
542// modification, are permitted provided that the following conditions are
543// met:
544//
545//     * Redistributions of source code must retain the above copyright
546// notice, this list of conditions and the following disclaimer.
547//     * Redistributions in binary form must reproduce the above
548// copyright notice, this list of conditions and the following disclaimer
549// in the documentation and/or other materials provided with the
550// distribution.
551//     * Neither the name of Google Inc. nor the names of its
552// contributors may be used to endorse or promote products derived from
553// this software without specific prior written permission.
554//
555// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
556// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
557// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
558// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
559// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
560// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
561// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
562// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
563// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
564// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
565// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
566//
567// Author: wan@google.com (Zhanyong Wan)
568
569// Implements a subset of TR1 tuple needed by Google Test and Google Mock.
570
571#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
572#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
573
574#include <utility>  // For ::std::pair.
575
576// The compiler used in Symbian has a bug that prevents us from declaring the
577// tuple template as a friend (it complains that tuple is redefined).  This
578// hack bypasses the bug by declaring the members that should otherwise be
579// private as public.
580// Sun Studio versions < 12 also have the above bug.
581#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)
582#define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:
583#else
584#define GTEST_DECLARE_TUPLE_AS_FRIEND_ \
585    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \
586   private:
587#endif
588
589// GTEST_n_TUPLE_(T) is the type of an n-tuple.
590#define GTEST_0_TUPLE_(T) tuple<>
591#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \
592    void, void, void>
593#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \
594    void, void, void>
595#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \
596    void, void, void>
597#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \
598    void, void, void>
599#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \
600    void, void, void>
601#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \
602    void, void, void>
603#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
604    void, void, void>
605#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
606    T##7, void, void>
607#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
608    T##7, T##8, void>
609#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \
610    T##7, T##8, T##9>
611
612// GTEST_n_TYPENAMES_(T) declares a list of n typenames.
613#define GTEST_0_TYPENAMES_(T)
614#define GTEST_1_TYPENAMES_(T) typename T##0
615#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1
616#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2
617#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
618    typename T##3
619#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
620    typename T##3, typename T##4
621#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
622    typename T##3, typename T##4, typename T##5
623#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
624    typename T##3, typename T##4, typename T##5, typename T##6
625#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
626    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7
627#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
628    typename T##3, typename T##4, typename T##5, typename T##6, \
629    typename T##7, typename T##8
630#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \
631    typename T##3, typename T##4, typename T##5, typename T##6, \
632    typename T##7, typename T##8, typename T##9
633
634// In theory, defining stuff in the ::std namespace is undefined
635// behavior.  We can do this as we are playing the role of a standard
636// library vendor.
637namespace std {
638namespace tr1 {
639
640template <typename T0 = void, typename T1 = void, typename T2 = void,
641    typename T3 = void, typename T4 = void, typename T5 = void,
642    typename T6 = void, typename T7 = void, typename T8 = void,
643    typename T9 = void>
644class tuple;
645
646// Anything in namespace gtest_internal is Google Test's INTERNAL
647// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.
648namespace gtest_internal {
649
650// ByRef<T>::type is T if T is a reference; otherwise it's const T&.
651template <typename T>
652struct ByRef { typedef const T& type; };  // NOLINT
653template <typename T>
654struct ByRef<T&> { typedef T& type; };  // NOLINT
655
656// A handy wrapper for ByRef.
657#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type
658
659// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This
660// is the same as tr1::add_reference<T>::type.
661template <typename T>
662struct AddRef { typedef T& type; };  // NOLINT
663template <typename T>
664struct AddRef<T&> { typedef T& type; };  // NOLINT
665
666// A handy wrapper for AddRef.
667#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type
668
669// A helper for implementing get<k>().
670template <int k> class Get;
671
672// A helper for implementing tuple_element<k, T>.  kIndexValid is true
673// iff k < the number of fields in tuple type T.
674template <bool kIndexValid, int kIndex, class Tuple>
675struct TupleElement;
676
677template <GTEST_10_TYPENAMES_(T)>
678struct TupleElement<true, 0, GTEST_10_TUPLE_(T)> { typedef T0 type; };
679
680template <GTEST_10_TYPENAMES_(T)>
681struct TupleElement<true, 1, GTEST_10_TUPLE_(T)> { typedef T1 type; };
682
683template <GTEST_10_TYPENAMES_(T)>
684struct TupleElement<true, 2, GTEST_10_TUPLE_(T)> { typedef T2 type; };
685
686template <GTEST_10_TYPENAMES_(T)>
687struct TupleElement<true, 3, GTEST_10_TUPLE_(T)> { typedef T3 type; };
688
689template <GTEST_10_TYPENAMES_(T)>
690struct TupleElement<true, 4, GTEST_10_TUPLE_(T)> { typedef T4 type; };
691
692template <GTEST_10_TYPENAMES_(T)>
693struct TupleElement<true, 5, GTEST_10_TUPLE_(T)> { typedef T5 type; };
694
695template <GTEST_10_TYPENAMES_(T)>
696struct TupleElement<true, 6, GTEST_10_TUPLE_(T)> { typedef T6 type; };
697
698template <GTEST_10_TYPENAMES_(T)>
699struct TupleElement<true, 7, GTEST_10_TUPLE_(T)> { typedef T7 type; };
700
701template <GTEST_10_TYPENAMES_(T)>
702struct TupleElement<true, 8, GTEST_10_TUPLE_(T)> { typedef T8 type; };
703
704template <GTEST_10_TYPENAMES_(T)>
705struct TupleElement<true, 9, GTEST_10_TUPLE_(T)> { typedef T9 type; };
706
707}  // namespace gtest_internal
708
709template <>
710class tuple<> {
711 public:
712  tuple() {}
713  tuple(const tuple& /* t */)  {}
714  tuple& operator=(const tuple& /* t */) { return *this; }
715};
716
717template <GTEST_1_TYPENAMES_(T)>
718class GTEST_1_TUPLE_(T) {
719 public:
720  template <int k> friend class gtest_internal::Get;
721
722  tuple() : f0_() {}
723
724  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}
725
726  tuple(const tuple& t) : f0_(t.f0_) {}
727
728  template <GTEST_1_TYPENAMES_(U)>
729  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}
730
731  tuple& operator=(const tuple& t) { return CopyFrom(t); }
732
733  template <GTEST_1_TYPENAMES_(U)>
734  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {
735    return CopyFrom(t);
736  }
737
738  GTEST_DECLARE_TUPLE_AS_FRIEND_
739
740  template <GTEST_1_TYPENAMES_(U)>
741  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {
742    f0_ = t.f0_;
743    return *this;
744  }
745
746  T0 f0_;
747};
748
749template <GTEST_2_TYPENAMES_(T)>
750class GTEST_2_TUPLE_(T) {
751 public:
752  template <int k> friend class gtest_internal::Get;
753
754  tuple() : f0_(), f1_() {}
755
756  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),
757      f1_(f1) {}
758
759  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}
760
761  template <GTEST_2_TYPENAMES_(U)>
762  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}
763  template <typename U0, typename U1>
764  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}
765
766  tuple& operator=(const tuple& t) { return CopyFrom(t); }
767
768  template <GTEST_2_TYPENAMES_(U)>
769  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {
770    return CopyFrom(t);
771  }
772  template <typename U0, typename U1>
773  tuple& operator=(const ::std::pair<U0, U1>& p) {
774    f0_ = p.first;
775    f1_ = p.second;
776    return *this;
777  }
778
779  GTEST_DECLARE_TUPLE_AS_FRIEND_
780
781  template <GTEST_2_TYPENAMES_(U)>
782  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {
783    f0_ = t.f0_;
784    f1_ = t.f1_;
785    return *this;
786  }
787
788  T0 f0_;
789  T1 f1_;
790};
791
792template <GTEST_3_TYPENAMES_(T)>
793class GTEST_3_TUPLE_(T) {
794 public:
795  template <int k> friend class gtest_internal::Get;
796
797  tuple() : f0_(), f1_(), f2_() {}
798
799  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
800      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}
801
802  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
803
804  template <GTEST_3_TYPENAMES_(U)>
805  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}
806
807  tuple& operator=(const tuple& t) { return CopyFrom(t); }
808
809  template <GTEST_3_TYPENAMES_(U)>
810  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {
811    return CopyFrom(t);
812  }
813
814  GTEST_DECLARE_TUPLE_AS_FRIEND_
815
816  template <GTEST_3_TYPENAMES_(U)>
817  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {
818    f0_ = t.f0_;
819    f1_ = t.f1_;
820    f2_ = t.f2_;
821    return *this;
822  }
823
824  T0 f0_;
825  T1 f1_;
826  T2 f2_;
827};
828
829template <GTEST_4_TYPENAMES_(T)>
830class GTEST_4_TUPLE_(T) {
831 public:
832  template <int k> friend class gtest_internal::Get;
833
834  tuple() : f0_(), f1_(), f2_(), f3_() {}
835
836  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
837      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),
838      f3_(f3) {}
839
840  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}
841
842  template <GTEST_4_TYPENAMES_(U)>
843  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
844      f3_(t.f3_) {}
845
846  tuple& operator=(const tuple& t) { return CopyFrom(t); }
847
848  template <GTEST_4_TYPENAMES_(U)>
849  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {
850    return CopyFrom(t);
851  }
852
853  GTEST_DECLARE_TUPLE_AS_FRIEND_
854
855  template <GTEST_4_TYPENAMES_(U)>
856  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {
857    f0_ = t.f0_;
858    f1_ = t.f1_;
859    f2_ = t.f2_;
860    f3_ = t.f3_;
861    return *this;
862  }
863
864  T0 f0_;
865  T1 f1_;
866  T2 f2_;
867  T3 f3_;
868};
869
870template <GTEST_5_TYPENAMES_(T)>
871class GTEST_5_TUPLE_(T) {
872 public:
873  template <int k> friend class gtest_internal::Get;
874
875  tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}
876
877  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
878      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,
879      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}
880
881  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
882      f4_(t.f4_) {}
883
884  template <GTEST_5_TYPENAMES_(U)>
885  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
886      f3_(t.f3_), f4_(t.f4_) {}
887
888  tuple& operator=(const tuple& t) { return CopyFrom(t); }
889
890  template <GTEST_5_TYPENAMES_(U)>
891  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {
892    return CopyFrom(t);
893  }
894
895  GTEST_DECLARE_TUPLE_AS_FRIEND_
896
897  template <GTEST_5_TYPENAMES_(U)>
898  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {
899    f0_ = t.f0_;
900    f1_ = t.f1_;
901    f2_ = t.f2_;
902    f3_ = t.f3_;
903    f4_ = t.f4_;
904    return *this;
905  }
906
907  T0 f0_;
908  T1 f1_;
909  T2 f2_;
910  T3 f3_;
911  T4 f4_;
912};
913
914template <GTEST_6_TYPENAMES_(T)>
915class GTEST_6_TUPLE_(T) {
916 public:
917  template <int k> friend class gtest_internal::Get;
918
919  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}
920
921  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
922      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
923      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
924      f5_(f5) {}
925
926  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
927      f4_(t.f4_), f5_(t.f5_) {}
928
929  template <GTEST_6_TYPENAMES_(U)>
930  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
931      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}
932
933  tuple& operator=(const tuple& t) { return CopyFrom(t); }
934
935  template <GTEST_6_TYPENAMES_(U)>
936  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {
937    return CopyFrom(t);
938  }
939
940  GTEST_DECLARE_TUPLE_AS_FRIEND_
941
942  template <GTEST_6_TYPENAMES_(U)>
943  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {
944    f0_ = t.f0_;
945    f1_ = t.f1_;
946    f2_ = t.f2_;
947    f3_ = t.f3_;
948    f4_ = t.f4_;
949    f5_ = t.f5_;
950    return *this;
951  }
952
953  T0 f0_;
954  T1 f1_;
955  T2 f2_;
956  T3 f3_;
957  T4 f4_;
958  T5 f5_;
959};
960
961template <GTEST_7_TYPENAMES_(T)>
962class GTEST_7_TUPLE_(T) {
963 public:
964  template <int k> friend class gtest_internal::Get;
965
966  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}
967
968  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
969      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
970      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),
971      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}
972
973  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
974      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
975
976  template <GTEST_7_TYPENAMES_(U)>
977  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
978      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}
979
980  tuple& operator=(const tuple& t) { return CopyFrom(t); }
981
982  template <GTEST_7_TYPENAMES_(U)>
983  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {
984    return CopyFrom(t);
985  }
986
987  GTEST_DECLARE_TUPLE_AS_FRIEND_
988
989  template <GTEST_7_TYPENAMES_(U)>
990  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {
991    f0_ = t.f0_;
992    f1_ = t.f1_;
993    f2_ = t.f2_;
994    f3_ = t.f3_;
995    f4_ = t.f4_;
996    f5_ = t.f5_;
997    f6_ = t.f6_;
998    return *this;
999  }
1000
1001  T0 f0_;
1002  T1 f1_;
1003  T2 f2_;
1004  T3 f3_;
1005  T4 f4_;
1006  T5 f5_;
1007  T6 f6_;
1008};
1009
1010template <GTEST_8_TYPENAMES_(T)>
1011class GTEST_8_TUPLE_(T) {
1012 public:
1013  template <int k> friend class gtest_internal::Get;
1014
1015  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}
1016
1017  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1018      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1019      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,
1020      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
1021      f5_(f5), f6_(f6), f7_(f7) {}
1022
1023  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1024      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
1025
1026  template <GTEST_8_TYPENAMES_(U)>
1027  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1028      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}
1029
1030  tuple& operator=(const tuple& t) { return CopyFrom(t); }
1031
1032  template <GTEST_8_TYPENAMES_(U)>
1033  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {
1034    return CopyFrom(t);
1035  }
1036
1037  GTEST_DECLARE_TUPLE_AS_FRIEND_
1038
1039  template <GTEST_8_TYPENAMES_(U)>
1040  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {
1041    f0_ = t.f0_;
1042    f1_ = t.f1_;
1043    f2_ = t.f2_;
1044    f3_ = t.f3_;
1045    f4_ = t.f4_;
1046    f5_ = t.f5_;
1047    f6_ = t.f6_;
1048    f7_ = t.f7_;
1049    return *this;
1050  }
1051
1052  T0 f0_;
1053  T1 f1_;
1054  T2 f2_;
1055  T3 f3_;
1056  T4 f4_;
1057  T5 f5_;
1058  T6 f6_;
1059  T7 f7_;
1060};
1061
1062template <GTEST_9_TYPENAMES_(T)>
1063class GTEST_9_TUPLE_(T) {
1064 public:
1065  template <int k> friend class gtest_internal::Get;
1066
1067  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}
1068
1069  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1070      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1071      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
1072      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),
1073      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}
1074
1075  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1076      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
1077
1078  template <GTEST_9_TYPENAMES_(U)>
1079  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1080      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}
1081
1082  tuple& operator=(const tuple& t) { return CopyFrom(t); }
1083
1084  template <GTEST_9_TYPENAMES_(U)>
1085  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {
1086    return CopyFrom(t);
1087  }
1088
1089  GTEST_DECLARE_TUPLE_AS_FRIEND_
1090
1091  template <GTEST_9_TYPENAMES_(U)>
1092  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {
1093    f0_ = t.f0_;
1094    f1_ = t.f1_;
1095    f2_ = t.f2_;
1096    f3_ = t.f3_;
1097    f4_ = t.f4_;
1098    f5_ = t.f5_;
1099    f6_ = t.f6_;
1100    f7_ = t.f7_;
1101    f8_ = t.f8_;
1102    return *this;
1103  }
1104
1105  T0 f0_;
1106  T1 f1_;
1107  T2 f2_;
1108  T3 f3_;
1109  T4 f4_;
1110  T5 f5_;
1111  T6 f6_;
1112  T7 f7_;
1113  T8 f8_;
1114};
1115
1116template <GTEST_10_TYPENAMES_(T)>
1117class tuple {
1118 public:
1119  template <int k> friend class gtest_internal::Get;
1120
1121  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),
1122      f9_() {}
1123
1124  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,
1125      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,
1126      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,
1127      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),
1128      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}
1129
1130  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),
1131      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}
1132
1133  template <GTEST_10_TYPENAMES_(U)>
1134  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),
1135      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),
1136      f9_(t.f9_) {}
1137
1138  tuple& operator=(const tuple& t) { return CopyFrom(t); }
1139
1140  template <GTEST_10_TYPENAMES_(U)>
1141  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {
1142    return CopyFrom(t);
1143  }
1144
1145  GTEST_DECLARE_TUPLE_AS_FRIEND_
1146
1147  template <GTEST_10_TYPENAMES_(U)>
1148  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {
1149    f0_ = t.f0_;
1150    f1_ = t.f1_;
1151    f2_ = t.f2_;
1152    f3_ = t.f3_;
1153    f4_ = t.f4_;
1154    f5_ = t.f5_;
1155    f6_ = t.f6_;
1156    f7_ = t.f7_;
1157    f8_ = t.f8_;
1158    f9_ = t.f9_;
1159    return *this;
1160  }
1161
1162  T0 f0_;
1163  T1 f1_;
1164  T2 f2_;
1165  T3 f3_;
1166  T4 f4_;
1167  T5 f5_;
1168  T6 f6_;
1169  T7 f7_;
1170  T8 f8_;
1171  T9 f9_;
1172};
1173
1174// 6.1.3.2 Tuple creation functions.
1175
1176// Known limitations: we don't support passing an
1177// std::tr1::reference_wrapper<T> to make_tuple().  And we don't
1178// implement tie().
1179
1180inline tuple<> make_tuple() { return tuple<>(); }
1181
1182template <GTEST_1_TYPENAMES_(T)>
1183inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {
1184  return GTEST_1_TUPLE_(T)(f0);
1185}
1186
1187template <GTEST_2_TYPENAMES_(T)>
1188inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {
1189  return GTEST_2_TUPLE_(T)(f0, f1);
1190}
1191
1192template <GTEST_3_TYPENAMES_(T)>
1193inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {
1194  return GTEST_3_TUPLE_(T)(f0, f1, f2);
1195}
1196
1197template <GTEST_4_TYPENAMES_(T)>
1198inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1199    const T3& f3) {
1200  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);
1201}
1202
1203template <GTEST_5_TYPENAMES_(T)>
1204inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1205    const T3& f3, const T4& f4) {
1206  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);
1207}
1208
1209template <GTEST_6_TYPENAMES_(T)>
1210inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1211    const T3& f3, const T4& f4, const T5& f5) {
1212  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);
1213}
1214
1215template <GTEST_7_TYPENAMES_(T)>
1216inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1217    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {
1218  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);
1219}
1220
1221template <GTEST_8_TYPENAMES_(T)>
1222inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1223    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {
1224  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);
1225}
1226
1227template <GTEST_9_TYPENAMES_(T)>
1228inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1229    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
1230    const T8& f8) {
1231  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);
1232}
1233
1234template <GTEST_10_TYPENAMES_(T)>
1235inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,
1236    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,
1237    const T8& f8, const T9& f9) {
1238  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);
1239}
1240
1241// 6.1.3.3 Tuple helper classes.
1242
1243template <typename Tuple> struct tuple_size;
1244
1245template <GTEST_0_TYPENAMES_(T)>
1246struct tuple_size<GTEST_0_TUPLE_(T)> { static const int value = 0; };
1247
1248template <GTEST_1_TYPENAMES_(T)>
1249struct tuple_size<GTEST_1_TUPLE_(T)> { static const int value = 1; };
1250
1251template <GTEST_2_TYPENAMES_(T)>
1252struct tuple_size<GTEST_2_TUPLE_(T)> { static const int value = 2; };
1253
1254template <GTEST_3_TYPENAMES_(T)>
1255struct tuple_size<GTEST_3_TUPLE_(T)> { static const int value = 3; };
1256
1257template <GTEST_4_TYPENAMES_(T)>
1258struct tuple_size<GTEST_4_TUPLE_(T)> { static const int value = 4; };
1259
1260template <GTEST_5_TYPENAMES_(T)>
1261struct tuple_size<GTEST_5_TUPLE_(T)> { static const int value = 5; };
1262
1263template <GTEST_6_TYPENAMES_(T)>
1264struct tuple_size<GTEST_6_TUPLE_(T)> { static const int value = 6; };
1265
1266template <GTEST_7_TYPENAMES_(T)>
1267struct tuple_size<GTEST_7_TUPLE_(T)> { static const int value = 7; };
1268
1269template <GTEST_8_TYPENAMES_(T)>
1270struct tuple_size<GTEST_8_TUPLE_(T)> { static const int value = 8; };
1271
1272template <GTEST_9_TYPENAMES_(T)>
1273struct tuple_size<GTEST_9_TUPLE_(T)> { static const int value = 9; };
1274
1275template <GTEST_10_TYPENAMES_(T)>
1276struct tuple_size<GTEST_10_TUPLE_(T)> { static const int value = 10; };
1277
1278template <int k, class Tuple>
1279struct tuple_element {
1280  typedef typename gtest_internal::TupleElement<
1281      k < (tuple_size<Tuple>::value), k, Tuple>::type type;
1282};
1283
1284#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type
1285
1286// 6.1.3.4 Element access.
1287
1288namespace gtest_internal {
1289
1290template <>
1291class Get<0> {
1292 public:
1293  template <class Tuple>
1294  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
1295  Field(Tuple& t) { return t.f0_; }  // NOLINT
1296
1297  template <class Tuple>
1298  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))
1299  ConstField(const Tuple& t) { return t.f0_; }
1300};
1301
1302template <>
1303class Get<1> {
1304 public:
1305  template <class Tuple>
1306  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
1307  Field(Tuple& t) { return t.f1_; }  // NOLINT
1308
1309  template <class Tuple>
1310  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))
1311  ConstField(const Tuple& t) { return t.f1_; }
1312};
1313
1314template <>
1315class Get<2> {
1316 public:
1317  template <class Tuple>
1318  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
1319  Field(Tuple& t) { return t.f2_; }  // NOLINT
1320
1321  template <class Tuple>
1322  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))
1323  ConstField(const Tuple& t) { return t.f2_; }
1324};
1325
1326template <>
1327class Get<3> {
1328 public:
1329  template <class Tuple>
1330  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
1331  Field(Tuple& t) { return t.f3_; }  // NOLINT
1332
1333  template <class Tuple>
1334  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))
1335  ConstField(const Tuple& t) { return t.f3_; }
1336};
1337
1338template <>
1339class Get<4> {
1340 public:
1341  template <class Tuple>
1342  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
1343  Field(Tuple& t) { return t.f4_; }  // NOLINT
1344
1345  template <class Tuple>
1346  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))
1347  ConstField(const Tuple& t) { return t.f4_; }
1348};
1349
1350template <>
1351class Get<5> {
1352 public:
1353  template <class Tuple>
1354  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
1355  Field(Tuple& t) { return t.f5_; }  // NOLINT
1356
1357  template <class Tuple>
1358  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))
1359  ConstField(const Tuple& t) { return t.f5_; }
1360};
1361
1362template <>
1363class Get<6> {
1364 public:
1365  template <class Tuple>
1366  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
1367  Field(Tuple& t) { return t.f6_; }  // NOLINT
1368
1369  template <class Tuple>
1370  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))
1371  ConstField(const Tuple& t) { return t.f6_; }
1372};
1373
1374template <>
1375class Get<7> {
1376 public:
1377  template <class Tuple>
1378  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
1379  Field(Tuple& t) { return t.f7_; }  // NOLINT
1380
1381  template <class Tuple>
1382  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))
1383  ConstField(const Tuple& t) { return t.f7_; }
1384};
1385
1386template <>
1387class Get<8> {
1388 public:
1389  template <class Tuple>
1390  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
1391  Field(Tuple& t) { return t.f8_; }  // NOLINT
1392
1393  template <class Tuple>
1394  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))
1395  ConstField(const Tuple& t) { return t.f8_; }
1396};
1397
1398template <>
1399class Get<9> {
1400 public:
1401  template <class Tuple>
1402  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
1403  Field(Tuple& t) { return t.f9_; }  // NOLINT
1404
1405  template <class Tuple>
1406  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))
1407  ConstField(const Tuple& t) { return t.f9_; }
1408};
1409
1410}  // namespace gtest_internal
1411
1412template <int k, GTEST_10_TYPENAMES_(T)>
1413GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))
1414get(GTEST_10_TUPLE_(T)& t) {
1415  return gtest_internal::Get<k>::Field(t);
1416}
1417
1418template <int k, GTEST_10_TYPENAMES_(T)>
1419GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))
1420get(const GTEST_10_TUPLE_(T)& t) {
1421  return gtest_internal::Get<k>::ConstField(t);
1422}
1423
1424// 6.1.3.5 Relational operators
1425
1426// We only implement == and !=, as we don't have a need for the rest yet.
1427
1428namespace gtest_internal {
1429
1430// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the
1431// first k fields of t1 equals the first k fields of t2.
1432// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if
1433// k1 != k2.
1434template <int kSize1, int kSize2>
1435struct SameSizeTuplePrefixComparator;
1436
1437template <>
1438struct SameSizeTuplePrefixComparator<0, 0> {
1439  template <class Tuple1, class Tuple2>
1440  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {
1441    return true;
1442  }
1443};
1444
1445template <int k>
1446struct SameSizeTuplePrefixComparator<k, k> {
1447  template <class Tuple1, class Tuple2>
1448  static bool Eq(const Tuple1& t1, const Tuple2& t2) {
1449    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&
1450        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);
1451  }
1452};
1453
1454}  // namespace gtest_internal
1455
1456template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
1457inline bool operator==(const GTEST_10_TUPLE_(T)& t,
1458                       const GTEST_10_TUPLE_(U)& u) {
1459  return gtest_internal::SameSizeTuplePrefixComparator<
1460      tuple_size<GTEST_10_TUPLE_(T)>::value,
1461      tuple_size<GTEST_10_TUPLE_(U)>::value>::Eq(t, u);
1462}
1463
1464template <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>
1465inline bool operator!=(const GTEST_10_TUPLE_(T)& t,
1466                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }
1467
1468// 6.1.4 Pairs.
1469// Unimplemented.
1470
1471}  // namespace tr1
1472}  // namespace std
1473
1474#undef GTEST_0_TUPLE_
1475#undef GTEST_1_TUPLE_
1476#undef GTEST_2_TUPLE_
1477#undef GTEST_3_TUPLE_
1478#undef GTEST_4_TUPLE_
1479#undef GTEST_5_TUPLE_
1480#undef GTEST_6_TUPLE_
1481#undef GTEST_7_TUPLE_
1482#undef GTEST_8_TUPLE_
1483#undef GTEST_9_TUPLE_
1484#undef GTEST_10_TUPLE_
1485
1486#undef GTEST_0_TYPENAMES_
1487#undef GTEST_1_TYPENAMES_
1488#undef GTEST_2_TYPENAMES_
1489#undef GTEST_3_TYPENAMES_
1490#undef GTEST_4_TYPENAMES_
1491#undef GTEST_5_TYPENAMES_
1492#undef GTEST_6_TYPENAMES_
1493#undef GTEST_7_TYPENAMES_
1494#undef GTEST_8_TYPENAMES_
1495#undef GTEST_9_TYPENAMES_
1496#undef GTEST_10_TYPENAMES_
1497
1498#undef GTEST_DECLARE_TUPLE_AS_FRIEND_
1499#undef GTEST_BY_REF_
1500#undef GTEST_ADD_REF_
1501#undef GTEST_TUPLE_ELEMENT_
1502
1503#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_
1504#elif GTEST_OS_SYMBIAN
1505
1506// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
1507// use STLport's tuple implementation, which unfortunately doesn't
1508// work as the copy of STLport distributed with Symbian is incomplete.
1509// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to
1510// use its own tuple implementation.
1511#ifdef BOOST_HAS_TR1_TUPLE
1512#undef BOOST_HAS_TR1_TUPLE
1513#endif  // BOOST_HAS_TR1_TUPLE
1514
1515// This prevents <boost/tr1/detail/config.hpp>, which defines
1516// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.
1517#define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED
1518#include <tuple>
1519
1520#elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)
1521// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does
1522// not conform to the TR1 spec, which requires the header to be <tuple>.
1523
1524#if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
1525// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,
1526// which is #included by <tr1/tuple>, to not compile when RTTI is
1527// disabled.  _TR1_FUNCTIONAL is the header guard for
1528// <tr1/functional>.  Hence the following #define is a hack to prevent
1529// <tr1/functional> from being included.
1530#define _TR1_FUNCTIONAL 1
1531#include <tr1/tuple>
1532#undef _TR1_FUNCTIONAL  // Allows the user to #include
1533                        // <tr1/functional> if he chooses to.
1534#else
1535#include <tr1/tuple>  // NOLINT
1536#endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302
1537
1538#else
1539// If the compiler is not GCC 4.0+, we assume the user is using a
1540// spec-conforming TR1 implementation.
1541#include <tuple>  // NOLINT
1542#endif  // GTEST_USE_OWN_TR1_TUPLE
1543
1544#endif  // GTEST_HAS_TR1_TUPLE
1545
1546// Determines whether clone(2) is supported.
1547// Usually it will only be available on Linux, excluding
1548// Linux on the Itanium architecture.
1549// Also see http://linux.die.net/man/2/clone.
1550#ifndef GTEST_HAS_CLONE
1551// The user didn't tell us, so we need to figure it out.
1552
1553#if GTEST_OS_LINUX && !defined(__ia64__)
1554#define GTEST_HAS_CLONE 1
1555#else
1556#define GTEST_HAS_CLONE 0
1557#endif  // GTEST_OS_LINUX && !defined(__ia64__)
1558
1559#endif  // GTEST_HAS_CLONE
1560
1561// Determines whether to support stream redirection. This is used to test
1562// output correctness and to implement death tests.
1563#if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
1564#define GTEST_HAS_STREAM_REDIRECTION_ 1
1565#endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN
1566
1567// Determines whether to support death tests.
1568// Google Test does not support death tests for VC 7.1 and earlier as
1569// abort() in a VC 7.1 application compiled as GUI in debug config
1570// pops up a dialog window that cannot be suppressed programmatically.
1571#if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \
1572     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
1573     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX)
1574#define GTEST_HAS_DEATH_TEST 1
1575#include <vector>  // NOLINT
1576#endif
1577
1578// We don't support MSVC 7.1 with exceptions disabled now.  Therefore
1579// all the compilers we care about are adequate for supporting
1580// value-parameterized tests.
1581#define GTEST_HAS_PARAM_TEST 1
1582
1583// Determines whether to support type-driven tests.
1584
1585// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
1586// Sun Pro CC, and IBM Visual Age support.
1587#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \
1588    defined(__IBMCPP__)
1589#define GTEST_HAS_TYPED_TEST 1
1590#define GTEST_HAS_TYPED_TEST_P 1
1591#endif
1592
1593// Determines whether to support Combine(). This only makes sense when
1594// value-parameterized tests are enabled.  The implementation doesn't
1595// work on Sun Studio since it doesn't understand templated conversion
1596// operators.
1597#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)
1598#define GTEST_HAS_COMBINE 1
1599#endif
1600
1601// Determines whether the system compiler uses UTF-16 for encoding wide strings.
1602#define GTEST_WIDE_STRING_USES_UTF16_ \
1603    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
1604
1605// Defines some utility macros.
1606
1607// The GNU compiler emits a warning if nested "if" statements are followed by
1608// an "else" statement and braces are not used to explicitly disambiguate the
1609// "else" binding.  This leads to problems with code like:
1610//
1611//   if (gate)
1612//     ASSERT_*(condition) << "Some message";
1613//
1614// The "switch (0) case 0:" idiom is used to suppress this.
1615#ifdef __INTEL_COMPILER
1616#define GTEST_AMBIGUOUS_ELSE_BLOCKER_
1617#else
1618#define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0:  // NOLINT
1619#endif
1620
1621// Use this annotation at the end of a struct/class definition to
1622// prevent the compiler from optimizing away instances that are never
1623// used.  This is useful when all interesting logic happens inside the
1624// c'tor and / or d'tor.  Example:
1625//
1626//   struct Foo {
1627//     Foo() { ... }
1628//   } GTEST_ATTRIBUTE_UNUSED_;
1629//
1630// Also use it after a variable or parameter declaration to tell the
1631// compiler the variable/parameter does not have to be used.
1632#if defined(__GNUC__) && !defined(COMPILER_ICC)
1633#define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))
1634#else
1635#define GTEST_ATTRIBUTE_UNUSED_
1636#endif
1637
1638// A macro to disallow operator=
1639// This should be used in the private: declarations for a class.
1640#define GTEST_DISALLOW_ASSIGN_(type)\
1641  void operator=(type const &)
1642
1643// A macro to disallow copy constructor and operator=
1644// This should be used in the private: declarations for a class.
1645#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\
1646  type(type const &);\
1647  GTEST_DISALLOW_ASSIGN_(type)
1648
1649// Tell the compiler to warn about unused return values for functions declared
1650// with this macro.  The macro should be used on function declarations
1651// following the argument list:
1652//
1653//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;
1654#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)
1655#define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))
1656#else
1657#define GTEST_MUST_USE_RESULT_
1658#endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
1659
1660// Determine whether the compiler supports Microsoft's Structured Exception
1661// Handling.  This is supported by several Windows compilers but generally
1662// does not exist on any other system.
1663#ifndef GTEST_HAS_SEH
1664// The user didn't tell us, so we need to figure it out.
1665
1666#if defined(_MSC_VER) || defined(__BORLANDC__)
1667// These two compilers are known to support SEH.
1668#define GTEST_HAS_SEH 1
1669#else
1670// Assume no SEH.
1671#define GTEST_HAS_SEH 0
1672#endif
1673
1674#endif  // GTEST_HAS_SEH
1675
1676#ifdef _MSC_VER
1677
1678#if GTEST_LINKED_AS_SHARED_LIBRARY
1679#define GTEST_API_ __declspec(dllimport)
1680#elif GTEST_CREATE_SHARED_LIBRARY
1681#define GTEST_API_ __declspec(dllexport)
1682#endif
1683
1684#endif  // _MSC_VER
1685
1686#ifndef GTEST_API_
1687#define GTEST_API_
1688#endif
1689
1690namespace testing {
1691
1692class Message;
1693
1694namespace internal {
1695
1696class String;
1697
1698typedef ::std::stringstream StrStream;
1699
1700// A helper for suppressing warnings on constant condition.  It just
1701// returns 'condition'.
1702GTEST_API_ bool IsTrue(bool condition);
1703
1704// Defines scoped_ptr.
1705
1706// This implementation of scoped_ptr is PARTIAL - it only contains
1707// enough stuff to satisfy Google Test's need.
1708template <typename T>
1709class scoped_ptr {
1710 public:
1711  typedef T element_type;
1712
1713  explicit scoped_ptr(T* p = NULL) : ptr_(p) {}
1714  ~scoped_ptr() { reset(); }
1715
1716  T& operator*() const { return *ptr_; }
1717  T* operator->() const { return ptr_; }
1718  T* get() const { return ptr_; }
1719
1720  T* release() {
1721    T* const ptr = ptr_;
1722    ptr_ = NULL;
1723    return ptr;
1724  }
1725
1726  void reset(T* p = NULL) {
1727    if (p != ptr_) {
1728      if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.
1729        delete ptr_;
1730      }
1731      ptr_ = p;
1732    }
1733  }
1734 private:
1735  T* ptr_;
1736
1737  GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);
1738};
1739
1740// Defines RE.
1741
1742// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended
1743// Regular Expression syntax.
1744class GTEST_API_ RE {
1745 public:
1746  // A copy constructor is required by the Standard to initialize object
1747  // references from r-values.
1748  RE(const RE& other) { Init(other.pattern()); }
1749
1750  // Constructs an RE from a string.
1751  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT
1752
1753#if GTEST_HAS_GLOBAL_STRING
1754  RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT
1755#endif  // GTEST_HAS_GLOBAL_STRING
1756
1757  RE(const char* regex) { Init(regex); }  // NOLINT
1758  ~RE();
1759
1760  // Returns the string representation of the regex.
1761  const char* pattern() const { return pattern_; }
1762
1763  // FullMatch(str, re) returns true iff regular expression re matches
1764  // the entire str.
1765  // PartialMatch(str, re) returns true iff regular expression re
1766  // matches a substring of str (including str itself).
1767  //
1768  // TODO(wan@google.com): make FullMatch() and PartialMatch() work
1769  // when str contains NUL characters.
1770  static bool FullMatch(const ::std::string& str, const RE& re) {
1771    return FullMatch(str.c_str(), re);
1772  }
1773  static bool PartialMatch(const ::std::string& str, const RE& re) {
1774    return PartialMatch(str.c_str(), re);
1775  }
1776
1777#if GTEST_HAS_GLOBAL_STRING
1778  static bool FullMatch(const ::string& str, const RE& re) {
1779    return FullMatch(str.c_str(), re);
1780  }
1781  static bool PartialMatch(const ::string& str, const RE& re) {
1782    return PartialMatch(str.c_str(), re);
1783  }
1784#endif  // GTEST_HAS_GLOBAL_STRING
1785
1786  static bool FullMatch(const char* str, const RE& re);
1787  static bool PartialMatch(const char* str, const RE& re);
1788
1789 private:
1790  void Init(const char* regex);
1791
1792  // We use a const char* instead of a string, as Google Test may be used
1793  // where string is not available.  We also do not use Google Test's own
1794  // String type here, in order to simplify dependencies between the
1795  // files.
1796  const char* pattern_;
1797  bool is_valid_;
1798#if GTEST_USES_POSIX_RE
1799  regex_t full_regex_;     // For FullMatch().
1800  regex_t partial_regex_;  // For PartialMatch().
1801#else  // GTEST_USES_SIMPLE_RE
1802  const char* full_pattern_;  // For FullMatch();
1803#endif
1804
1805  GTEST_DISALLOW_ASSIGN_(RE);
1806};
1807
1808// Defines logging utilities:
1809//   GTEST_LOG_(severity) - logs messages at the specified severity level. The
1810//                          message itself is streamed into the macro.
1811//   LogToStderr()  - directs all log messages to stderr.
1812//   FlushInfoLog() - flushes informational log messages.
1813
1814enum GTestLogSeverity {
1815  GTEST_INFO,
1816  GTEST_WARNING,
1817  GTEST_ERROR,
1818  GTEST_FATAL
1819};
1820
1821// Formats log entry severity, provides a stream object for streaming the
1822// log message, and terminates the message with a newline when going out of
1823// scope.
1824class GTEST_API_ GTestLog {
1825 public:
1826  GTestLog(GTestLogSeverity severity, const char* file, int line);
1827
1828  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.
1829  ~GTestLog();
1830
1831  ::std::ostream& GetStream() { return ::std::cerr; }
1832
1833 private:
1834  const GTestLogSeverity severity_;
1835
1836  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);
1837};
1838
1839#define GTEST_LOG_(severity) \
1840    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \
1841                                  __FILE__, __LINE__).GetStream()
1842
1843inline void LogToStderr() {}
1844inline void FlushInfoLog() { fflush(NULL); }
1845
1846// INTERNAL IMPLEMENTATION - DO NOT USE.
1847//
1848// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition
1849// is not satisfied.
1850//  Synopsys:
1851//    GTEST_CHECK_(boolean_condition);
1852//     or
1853//    GTEST_CHECK_(boolean_condition) << "Additional message";
1854//
1855//    This checks the condition and if the condition is not satisfied
1856//    it prints message about the condition violation, including the
1857//    condition itself, plus additional message streamed into it, if any,
1858//    and then it aborts the program. It aborts the program irrespective of
1859//    whether it is built in the debug mode or not.
1860#define GTEST_CHECK_(condition) \
1861    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
1862    if (::testing::internal::IsTrue(condition)) \
1863      ; \
1864    else \
1865      GTEST_LOG_(FATAL) << "Condition " #condition " failed. "
1866
1867// An all-mode assert to verify that the given POSIX-style function
1868// call returns 0 (indicating success).  Known limitation: this
1869// doesn't expand to a balanced 'if' statement, so enclose the macro
1870// in {} if you need to use it as the only statement in an 'if'
1871// branch.
1872#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \
1873  if (const int gtest_error = (posix_call)) \
1874    GTEST_LOG_(FATAL) << #posix_call << "failed with error " \
1875                      << gtest_error
1876
1877// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
1878//
1879// Downcasts the pointer of type Base to Derived.
1880// Derived must be a subclass of Base. The parameter MUST
1881// point to a class of type Derived, not any subclass of it.
1882// When RTTI is available, the function performs a runtime
1883// check to enforce this.
1884template <class Derived, class Base>
1885Derived* CheckedDowncastToActualType(Base* base) {
1886#if GTEST_HAS_RTTI
1887  GTEST_CHECK_(typeid(*base) == typeid(Derived));
1888  return dynamic_cast<Derived*>(base);  // NOLINT
1889#else
1890  return static_cast<Derived*>(base);  // Poor man's downcast.
1891#endif
1892}
1893
1894#if GTEST_HAS_STREAM_REDIRECTION_
1895
1896// Defines the stderr capturer:
1897//   CaptureStdout     - starts capturing stdout.
1898//   GetCapturedStdout - stops capturing stdout and returns the captured string.
1899//   CaptureStderr     - starts capturing stderr.
1900//   GetCapturedStderr - stops capturing stderr and returns the captured string.
1901//
1902GTEST_API_ void CaptureStdout();
1903GTEST_API_ String GetCapturedStdout();
1904GTEST_API_ void CaptureStderr();
1905GTEST_API_ String GetCapturedStderr();
1906
1907#endif  // GTEST_HAS_STREAM_REDIRECTION_
1908
1909
1910#if GTEST_HAS_DEATH_TEST
1911
1912// A copy of all command line arguments.  Set by InitGoogleTest().
1913extern ::std::vector<String> g_argvs;
1914
1915// GTEST_HAS_DEATH_TEST implies we have ::std::string.
1916const ::std::vector<String>& GetArgvs();
1917
1918#endif  // GTEST_HAS_DEATH_TEST
1919
1920// Defines synchronization primitives.
1921
1922#if GTEST_HAS_PTHREAD
1923
1924// Sleeps for (roughly) n milli-seconds.  This function is only for
1925// testing Google Test's own constructs.  Don't use it in user tests,
1926// either directly or indirectly.
1927inline void SleepMilliseconds(int n) {
1928  const timespec time = {
1929    0,                  // 0 seconds.
1930    n * 1000L * 1000L,  // And n ms.
1931  };
1932  nanosleep(&time, NULL);
1933}
1934
1935// Allows a controller thread to pause execution of newly created
1936// threads until notified.  Instances of this class must be created
1937// and destroyed in the controller thread.
1938//
1939// This class is only for testing Google Test's own constructs. Do not
1940// use it in user tests, either directly or indirectly.
1941class Notification {
1942 public:
1943  Notification() : notified_(false) {}
1944
1945  // Notifies all threads created with this notification to start. Must
1946  // be called from the controller thread.
1947  void Notify() { notified_ = true; }
1948
1949  // Blocks until the controller thread notifies. Must be called from a test
1950  // thread.
1951  void WaitForNotification() {
1952    while(!notified_) {
1953      SleepMilliseconds(10);
1954    }
1955  }
1956
1957 private:
1958  volatile bool notified_;
1959
1960  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);
1961};
1962
1963// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.
1964// Consequently, it cannot select a correct instantiation of ThreadWithParam
1965// in order to call its Run(). Introducing ThreadWithParamBase as a
1966// non-templated base class for ThreadWithParam allows us to bypass this
1967// problem.
1968class ThreadWithParamBase {
1969 public:
1970  virtual ~ThreadWithParamBase() {}
1971  virtual void Run() = 0;
1972};
1973
1974// pthread_create() accepts a pointer to a function type with the C linkage.
1975// According to the Standard (7.5/1), function types with different linkages
1976// are different even if they are otherwise identical.  Some compilers (for
1977// example, SunStudio) treat them as different types.  Since class methods
1978// cannot be defined with C-linkage we need to define a free C-function to
1979// pass into pthread_create().
1980extern "C" inline void* ThreadFuncWithCLinkage(void* thread) {
1981  static_cast<ThreadWithParamBase*>(thread)->Run();
1982  return NULL;
1983}
1984
1985// Helper class for testing Google Test's multi-threading constructs.
1986// To use it, write:
1987//
1988//   void ThreadFunc(int param) { /* Do things with param */ }
1989//   Notification thread_can_start;
1990//   ...
1991//   // The thread_can_start parameter is optional; you can supply NULL.
1992//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);
1993//   thread_can_start.Notify();
1994//
1995// These classes are only for testing Google Test's own constructs. Do
1996// not use them in user tests, either directly or indirectly.
1997template <typename T>
1998class ThreadWithParam : public ThreadWithParamBase {
1999 public:
2000  typedef void (*UserThreadFunc)(T);
2001
2002  ThreadWithParam(
2003      UserThreadFunc func, T param, Notification* thread_can_start)
2004      : func_(func),
2005        param_(param),
2006        thread_can_start_(thread_can_start),
2007        finished_(false) {
2008    ThreadWithParamBase* const base = this;
2009    // The thread can be created only after all fields except thread_
2010    // have been initialized.
2011    GTEST_CHECK_POSIX_SUCCESS_(
2012        pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));
2013  }
2014  ~ThreadWithParam() { Join(); }
2015
2016  void Join() {
2017    if (!finished_) {
2018      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));
2019      finished_ = true;
2020    }
2021  }
2022
2023  virtual void Run() {
2024    if (thread_can_start_ != NULL)
2025      thread_can_start_->WaitForNotification();
2026    func_(param_);
2027  }
2028
2029 private:
2030  const UserThreadFunc func_;  // User-supplied thread function.
2031  const T param_;  // User-supplied parameter to the thread function.
2032  // When non-NULL, used to block execution until the controller thread
2033  // notifies.
2034  Notification* const thread_can_start_;
2035  bool finished_;  // true iff we know that the thread function has finished.
2036  pthread_t thread_;  // The native thread object.
2037
2038  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);
2039};
2040
2041// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is
2042// true.
2043#include <pthread.h>
2044
2045// MutexBase and Mutex implement mutex on pthreads-based platforms. They
2046// are used in conjunction with class MutexLock:
2047//
2048//   Mutex mutex;
2049//   ...
2050//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the end
2051//                            // of the current scope.
2052//
2053// MutexBase implements behavior for both statically and dynamically
2054// allocated mutexes.  Do not use MutexBase directly.  Instead, write
2055// the following to define a static mutex:
2056//
2057//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);
2058//
2059// You can forward declare a static mutex like this:
2060//
2061//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);
2062//
2063// To create a dynamic mutex, just define an object of type Mutex.
2064class MutexBase {
2065 public:
2066  // Acquires this mutex.
2067  void Lock() {
2068    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));
2069    owner_ = pthread_self();
2070  }
2071
2072  // Releases this mutex.
2073  void Unlock() {
2074    // We don't protect writing to owner_ here, as it's the caller's
2075    // responsibility to ensure that the current thread holds the
2076    // mutex when this is called.
2077    owner_ = 0;
2078    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));
2079  }
2080
2081  // Does nothing if the current thread holds the mutex. Otherwise, crashes
2082  // with high probability.
2083  void AssertHeld() const {
2084    GTEST_CHECK_(owner_ == pthread_self())
2085        << "The current thread is not holding the mutex @" << this;
2086  }
2087
2088  // A static mutex may be used before main() is entered.  It may even
2089  // be used before the dynamic initialization stage.  Therefore we
2090  // must be able to initialize a static mutex object at link time.
2091  // This means MutexBase has to be a POD and its member variables
2092  // have to be public.
2093 public:
2094  pthread_mutex_t mutex_;  // The underlying pthread mutex.
2095  pthread_t owner_;  // The thread holding the mutex; 0 means no one holds it.
2096};
2097
2098// Forward-declares a static mutex.
2099#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
2100    extern ::testing::internal::MutexBase mutex
2101
2102// Defines and statically (i.e. at link time) initializes a static mutex.
2103#define GTEST_DEFINE_STATIC_MUTEX_(mutex) \
2104    ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, 0 }
2105
2106// The Mutex class can only be used for mutexes created at runtime. It
2107// shares its API with MutexBase otherwise.
2108class Mutex : public MutexBase {
2109 public:
2110  Mutex() {
2111    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));
2112    owner_ = 0;
2113  }
2114  ~Mutex() {
2115    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));
2116  }
2117
2118 private:
2119  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);
2120};
2121
2122// We cannot name this class MutexLock as the ctor declaration would
2123// conflict with a macro named MutexLock, which is defined on some
2124// platforms.  Hence the typedef trick below.
2125class GTestMutexLock {
2126 public:
2127  explicit GTestMutexLock(MutexBase* mutex)
2128      : mutex_(mutex) { mutex_->Lock(); }
2129
2130  ~GTestMutexLock() { mutex_->Unlock(); }
2131
2132 private:
2133  MutexBase* const mutex_;
2134
2135  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);
2136};
2137
2138typedef GTestMutexLock MutexLock;
2139
2140// Helpers for ThreadLocal.
2141
2142// pthread_key_create() requires DeleteThreadLocalValue() to have
2143// C-linkage.  Therefore it cannot be templatized to access
2144// ThreadLocal<T>.  Hence the need for class
2145// ThreadLocalValueHolderBase.
2146class ThreadLocalValueHolderBase {
2147 public:
2148  virtual ~ThreadLocalValueHolderBase() {}
2149};
2150
2151// Called by pthread to delete thread-local data stored by
2152// pthread_setspecific().
2153extern "C" inline void DeleteThreadLocalValue(void* value_holder) {
2154  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);
2155}
2156
2157// Implements thread-local storage on pthreads-based systems.
2158//
2159//   // Thread 1
2160//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.
2161//
2162//   // Thread 2
2163//   tl.set(150);  // Changes the value for thread 2 only.
2164//   EXPECT_EQ(150, tl.get());
2165//
2166//   // Thread 1
2167//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.
2168//   tl.set(200);
2169//   EXPECT_EQ(200, tl.get());
2170//
2171// The template type argument T must have a public copy constructor.
2172// In addition, the default ThreadLocal constructor requires T to have
2173// a public default constructor.
2174//
2175// An object managed for a thread by a ThreadLocal instance is deleted
2176// when the thread exits.  Or, if the ThreadLocal instance dies in
2177// that thread, when the ThreadLocal dies.  It's the user's
2178// responsibility to ensure that all other threads using a ThreadLocal
2179// have exited when it dies, or the per-thread objects for those
2180// threads will not be deleted.
2181//
2182// Google Test only uses global ThreadLocal objects.  That means they
2183// will die after main() has returned.  Therefore, no per-thread
2184// object managed by Google Test will be leaked as long as all threads
2185// using Google Test have exited when main() returns.
2186template <typename T>
2187class ThreadLocal {
2188 public:
2189  ThreadLocal() : key_(CreateKey()),
2190                  default_() {}
2191  explicit ThreadLocal(const T& value) : key_(CreateKey()),
2192                                         default_(value) {}
2193
2194  ~ThreadLocal() {
2195    // Destroys the managed object for the current thread, if any.
2196    DeleteThreadLocalValue(pthread_getspecific(key_));
2197
2198    // Releases resources associated with the key.  This will *not*
2199    // delete managed objects for other threads.
2200    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));
2201  }
2202
2203  T* pointer() { return GetOrCreateValue(); }
2204  const T* pointer() const { return GetOrCreateValue(); }
2205  const T& get() const { return *pointer(); }
2206  void set(const T& value) { *pointer() = value; }
2207
2208 private:
2209  // Holds a value of type T.
2210  class ValueHolder : public ThreadLocalValueHolderBase {
2211   public:
2212    explicit ValueHolder(const T& value) : value_(value) {}
2213
2214    T* pointer() { return &value_; }
2215
2216   private:
2217    T value_;
2218    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);
2219  };
2220
2221  static pthread_key_t CreateKey() {
2222    pthread_key_t key;
2223    // When a thread exits, DeleteThreadLocalValue() will be called on
2224    // the object managed for that thread.
2225    GTEST_CHECK_POSIX_SUCCESS_(
2226        pthread_key_create(&key, &DeleteThreadLocalValue));
2227    return key;
2228  }
2229
2230  T* GetOrCreateValue() const {
2231    ThreadLocalValueHolderBase* const holder =
2232        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));
2233    if (holder != NULL) {
2234      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();
2235    }
2236
2237    ValueHolder* const new_holder = new ValueHolder(default_);
2238    ThreadLocalValueHolderBase* const holder_base = new_holder;
2239    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));
2240    return new_holder->pointer();
2241  }
2242
2243  // A key pthreads uses for looking up per-thread values.
2244  const pthread_key_t key_;
2245  const T default_;  // The default value for each thread.
2246
2247  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);
2248};
2249
2250#define GTEST_IS_THREADSAFE 1
2251
2252#else  // GTEST_HAS_PTHREAD
2253
2254// A dummy implementation of synchronization primitives (mutex, lock,
2255// and thread-local variable).  Necessary for compiling Google Test where
2256// mutex is not supported - using Google Test in multiple threads is not
2257// supported on such platforms.
2258
2259class Mutex {
2260 public:
2261  Mutex() {}
2262  void AssertHeld() const {}
2263};
2264
2265#define GTEST_DECLARE_STATIC_MUTEX_(mutex) \
2266  extern ::testing::internal::Mutex mutex
2267
2268#define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex
2269
2270class GTestMutexLock {
2271 public:
2272  explicit GTestMutexLock(Mutex*) {}  // NOLINT
2273};
2274
2275typedef GTestMutexLock MutexLock;
2276
2277template <typename T>
2278class ThreadLocal {
2279 public:
2280  ThreadLocal() : value_() {}
2281  explicit ThreadLocal(const T& value) : value_(value) {}
2282  T* pointer() { return &value_; }
2283  const T* pointer() const { return &value_; }
2284  const T& get() const { return value_; }
2285  void set(const T& value) { value_ = value; }
2286 private:
2287  T value_;
2288};
2289
2290// The above synchronization primitives have dummy implementations.
2291// Therefore Google Test is not thread-safe.
2292#define GTEST_IS_THREADSAFE 0
2293
2294#endif  // GTEST_HAS_PTHREAD
2295
2296// Returns the number of threads running in the process, or 0 to indicate that
2297// we cannot detect it.
2298GTEST_API_ size_t GetThreadCount();
2299
2300// Passing non-POD classes through ellipsis (...) crashes the ARM
2301// compiler and generates a warning in Sun Studio.  The Nokia Symbian
2302// and the IBM XL C/C++ compiler try to instantiate a copy constructor
2303// for objects passed through ellipsis (...), failing for uncopyable
2304// objects.  We define this to ensure that only POD is passed through
2305// ellipsis on these systems.
2306#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)
2307// We lose support for NULL detection where the compiler doesn't like
2308// passing non-POD classes through ellipsis (...).
2309#define GTEST_ELLIPSIS_NEEDS_POD_ 1
2310#else
2311#define GTEST_CAN_COMPARE_NULL 1
2312#endif
2313
2314// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between
2315// const T& and const T* in a function template.  These compilers
2316// _can_ decide between class template specializations for T and T*,
2317// so a tr1::type_traits-like is_pointer works.
2318#if defined(__SYMBIAN32__) || defined(__IBMCPP__)
2319#define GTEST_NEEDS_IS_POINTER_ 1
2320#endif
2321
2322template <bool bool_value>
2323struct bool_constant {
2324  typedef bool_constant<bool_value> type;
2325  static const bool value = bool_value;
2326};
2327template <bool bool_value> const bool bool_constant<bool_value>::value;
2328
2329typedef bool_constant<false> false_type;
2330typedef bool_constant<true> true_type;
2331
2332template <typename T>
2333struct is_pointer : public false_type {};
2334
2335template <typename T>
2336struct is_pointer<T*> : public true_type {};
2337
2338#if GTEST_OS_WINDOWS
2339#define GTEST_PATH_SEP_ "\\"
2340#define GTEST_HAS_ALT_PATH_SEP_ 1
2341// The biggest signed integer type the compiler supports.
2342typedef __int64 BiggestInt;
2343#else
2344#define GTEST_PATH_SEP_ "/"
2345#define GTEST_HAS_ALT_PATH_SEP_ 0
2346typedef long long BiggestInt;  // NOLINT
2347#endif  // GTEST_OS_WINDOWS
2348
2349// The testing::internal::posix namespace holds wrappers for common
2350// POSIX functions.  These wrappers hide the differences between
2351// Windows/MSVC and POSIX systems.  Since some compilers define these
2352// standard functions as macros, the wrapper cannot have the same name
2353// as the wrapped function.
2354
2355namespace posix {
2356
2357// Functions with a different name on Windows.
2358
2359#if GTEST_OS_WINDOWS
2360
2361typedef struct _stat StatStruct;
2362
2363#ifdef __BORLANDC__
2364inline int IsATTY(int fd) { return isatty(fd); }
2365inline int StrCaseCmp(const char* s1, const char* s2) {
2366  return stricmp(s1, s2);
2367}
2368inline char* StrDup(const char* src) { return strdup(src); }
2369#else  // !__BORLANDC__
2370#if GTEST_OS_WINDOWS_MOBILE
2371inline int IsATTY(int /* fd */) { return 0; }
2372#else
2373inline int IsATTY(int fd) { return _isatty(fd); }
2374#endif  // GTEST_OS_WINDOWS_MOBILE
2375inline int StrCaseCmp(const char* s1, const char* s2) {
2376  return _stricmp(s1, s2);
2377}
2378inline char* StrDup(const char* src) { return _strdup(src); }
2379#endif  // __BORLANDC__
2380
2381#if GTEST_OS_WINDOWS_MOBILE
2382inline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }
2383// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this
2384// time and thus not defined there.
2385#else
2386inline int FileNo(FILE* file) { return _fileno(file); }
2387inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }
2388inline int RmDir(const char* dir) { return _rmdir(dir); }
2389inline bool IsDir(const StatStruct& st) {
2390  return (_S_IFDIR & st.st_mode) != 0;
2391}
2392#endif  // GTEST_OS_WINDOWS_MOBILE
2393
2394#else
2395
2396typedef struct stat StatStruct;
2397
2398inline int FileNo(FILE* file) { return fileno(file); }
2399#if defined OCTEON_BUILD
2400inline int IsATTY(int fd) { return 0; }
2401inline int RmDir(const char* dir) { return 0; }
2402#else
2403inline int IsATTY(int fd) { return isatty(fd); }
2404inline int RmDir(const char* dir) { return rmdir(dir); }
2405#endif
2406inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }
2407inline int StrCaseCmp(const char* s1, const char* s2) {
2408  return strcasecmp(s1, s2);
2409}
2410inline char* StrDup(const char* src) { return strdup(src); }
2411inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }
2412
2413#endif  // GTEST_OS_WINDOWS
2414
2415// Functions deprecated by MSVC 8.0.
2416
2417#ifdef _MSC_VER
2418// Temporarily disable warning 4996 (deprecated function).
2419#pragma warning(push)
2420#pragma warning(disable:4996)
2421#endif
2422
2423inline const char* StrNCpy(char* dest, const char* src, size_t n) {
2424  return strncpy(dest, src, n);
2425}
2426
2427// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
2428// StrError() aren't needed on Windows CE at this time and thus not
2429// defined there.
2430
2431#if !GTEST_OS_WINDOWS_MOBILE
2432#ifdef OCTEON_BUILD
2433inline int ChDir(const char* dir) { return 0; }
2434#else
2435inline int ChDir(const char* dir) { return chdir(dir); }
2436#endif
2437#endif
2438inline FILE* FOpen(const char* path, const char* mode) {
2439  return fopen(path, mode);
2440}
2441#if !GTEST_OS_WINDOWS_MOBILE
2442inline FILE *FReopen(const char* path, const char* mode, FILE* stream) {
2443  return freopen(path, mode, stream);
2444}
2445inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
2446#endif
2447inline int FClose(FILE* fp) { return fclose(fp); }
2448#if !GTEST_OS_WINDOWS_MOBILE
2449#ifdef OCTEON_BUILD
2450inline int Read(int fd, void* buf, unsigned int count) {
2451  return 0;
2452}
2453inline int Write(int fd, const void* buf, unsigned int count) {
2454  return 0;
2455}
2456inline int Close(int fd) { return 0; }
2457
2458#else
2459inline int Read(int fd, void* buf, unsigned int count) {
2460  return static_cast<int>(read(fd, buf, count));
2461}
2462inline int Write(int fd, const void* buf, unsigned int count) {
2463  return static_cast<int>(write(fd, buf, count));
2464}
2465inline int Close(int fd) { return close(fd); }
2466inline const char* StrError(int errnum) { return strerror(errnum); }
2467#endif
2468#endif
2469inline const char* GetEnv(const char* name) {
2470#if GTEST_OS_WINDOWS_MOBILE
2471  // We are on Windows CE, which has no environment variables.
2472  return NULL;
2473#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
2474  // Environment variables which we programmatically clear will be set to the
2475  // empty string rather than unset (NULL).  Handle that case.
2476  const char* const env = getenv(name);
2477  return (env != NULL && env[0] != '\0') ? env : NULL;
2478#else
2479  return getenv(name);
2480#endif
2481}
2482
2483#ifdef _MSC_VER
2484#pragma warning(pop)  // Restores the warning state.
2485#endif
2486
2487#if GTEST_OS_WINDOWS_MOBILE
2488// Windows CE has no C library. The abort() function is used in
2489// several places in Google Test. This implementation provides a reasonable
2490// imitation of standard behaviour.
2491void Abort();
2492#else
2493inline void Abort() { abort(); }
2494#endif  // GTEST_OS_WINDOWS_MOBILE
2495
2496}  // namespace posix
2497
2498// The maximum number a BiggestInt can represent.  This definition
2499// works no matter BiggestInt is represented in one's complement or
2500// two's complement.
2501//
2502// We cannot rely on numeric_limits in STL, as __int64 and long long
2503// are not part of standard C++ and numeric_limits doesn't need to be
2504// defined for them.
2505const BiggestInt kMaxBiggestInt =
2506    ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
2507
2508// This template class serves as a compile-time function from size to
2509// type.  It maps a size in bytes to a primitive type with that
2510// size. e.g.
2511//
2512//   TypeWithSize<4>::UInt
2513//
2514// is typedef-ed to be unsigned int (unsigned integer made up of 4
2515// bytes).
2516//
2517// Such functionality should belong to STL, but I cannot find it
2518// there.
2519//
2520// Google Test uses this class in the implementation of floating-point
2521// comparison.
2522//
2523// For now it only handles UInt (unsigned int) as that's all Google Test
2524// needs.  Other types can be easily added in the future if need
2525// arises.
2526template <size_t size>
2527class TypeWithSize {
2528 public:
2529  // This prevents the user from using TypeWithSize<N> with incorrect
2530  // values of N.
2531  typedef void UInt;
2532};
2533
2534// The specialization for size 4.
2535template <>
2536class TypeWithSize<4> {
2537 public:
2538  // unsigned int has size 4 in both gcc and MSVC.
2539  //
2540  // As base/basictypes.h doesn't compile on Windows, we cannot use
2541  // uint32, uint64, and etc here.
2542  typedef int Int;
2543  typedef unsigned int UInt;
2544};
2545
2546// The specialization for size 8.
2547template <>
2548class TypeWithSize<8> {
2549 public:
2550#if GTEST_OS_WINDOWS
2551  typedef __int64 Int;
2552  typedef unsigned __int64 UInt;
2553#else
2554  typedef long long Int;  // NOLINT
2555  typedef unsigned long long UInt;  // NOLINT
2556#endif  // GTEST_OS_WINDOWS
2557};
2558
2559// Integer types of known sizes.
2560typedef TypeWithSize<4>::Int Int32;
2561typedef TypeWithSize<4>::UInt UInt32;
2562typedef TypeWithSize<8>::Int Int64;
2563typedef TypeWithSize<8>::UInt UInt64;
2564typedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.
2565
2566// Utilities for command line flags and environment variables.
2567
2568// Macro for referencing flags.
2569#define GTEST_FLAG(name) FLAGS_gtest_##name
2570
2571// Macros for declaring flags.
2572#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
2573#define GTEST_DECLARE_int32_(name) \
2574    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
2575#define GTEST_DECLARE_string_(name) \
2576    GTEST_API_ extern ::testing::internal::String GTEST_FLAG(name)
2577
2578// Macros for defining flags.
2579#define GTEST_DEFINE_bool_(name, default_val, doc) \
2580    GTEST_API_ bool GTEST_FLAG(name) = (default_val)
2581#define GTEST_DEFINE_int32_(name, default_val, doc) \
2582    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
2583#define GTEST_DEFINE_string_(name, default_val, doc) \
2584    GTEST_API_ ::testing::internal::String GTEST_FLAG(name) = (default_val)
2585
2586// Parses 'str' for a 32-bit signed integer.  If successful, writes the result
2587// to *value and returns true; otherwise leaves *value unchanged and returns
2588// false.
2589// TODO(chandlerc): Find a better way to refactor flag and environment parsing
2590// out of both gtest-port.cc and gtest.cc to avoid exporting this utility
2591// function.
2592bool ParseInt32(const Message& src_text, const char* str, Int32* value);
2593
2594// Parses a bool/Int32/string from the environment variable
2595// corresponding to the given Google Test flag.
2596bool BoolFromGTestEnv(const char* flag, bool default_val);
2597GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
2598const char* StringFromGTestEnv(const char* flag, const char* default_val);
2599
2600}  // namespace internal
2601}  // namespace testing
2602
2603#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
2604
2605#if GTEST_OS_LINUX
2606#include <stdlib.h>
2607#include <sys/types.h>
2608#include <sys/wait.h>
2609#include <unistd.h>
2610#endif  // GTEST_OS_LINUX
2611
2612#include <ctype.h>
2613#include <string.h>
2614#include <iomanip>
2615#include <limits>
2616#include <set>
2617
2618// Copyright 2005, Google Inc.
2619// All rights reserved.
2620//
2621// Redistribution and use in source and binary forms, with or without
2622// modification, are permitted provided that the following conditions are
2623// met:
2624//
2625//     * Redistributions of source code must retain the above copyright
2626// notice, this list of conditions and the following disclaimer.
2627//     * Redistributions in binary form must reproduce the above
2628// copyright notice, this list of conditions and the following disclaimer
2629// in the documentation and/or other materials provided with the
2630// distribution.
2631//     * Neither the name of Google Inc. nor the names of its
2632// contributors may be used to endorse or promote products derived from
2633// this software without specific prior written permission.
2634//
2635// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2636// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2637// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2638// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2639// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2640// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2641// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2642// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2643// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2644// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2645// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2646//
2647// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)
2648//
2649// The Google C++ Testing Framework (Google Test)
2650//
2651// This header file declares the String class and functions used internally by
2652// Google Test.  They are subject to change without notice. They should not used
2653// by code external to Google Test.
2654//
2655// This header file is #included by <gtest/internal/gtest-internal.h>.
2656// It should not be #included by other files.
2657
2658#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2659#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2660
2661#ifdef __BORLANDC__
2662// string.h is not guaranteed to provide strcpy on C++ Builder.
2663#include <mem.h>
2664#endif
2665
2666#include <string.h>
2667
2668#include <string>
2669
2670namespace testing {
2671namespace internal {
2672
2673// String - a UTF-8 string class.
2674//
2675// For historic reasons, we don't use std::string.
2676//
2677// TODO(wan@google.com): replace this class with std::string or
2678// implement it in terms of the latter.
2679//
2680// Note that String can represent both NULL and the empty string,
2681// while std::string cannot represent NULL.
2682//
2683// NULL and the empty string are considered different.  NULL is less
2684// than anything (including the empty string) except itself.
2685//
2686// This class only provides minimum functionality necessary for
2687// implementing Google Test.  We do not intend to implement a full-fledged
2688// string class here.
2689//
2690// Since the purpose of this class is to provide a substitute for
2691// std::string on platforms where it cannot be used, we define a copy
2692// constructor and assignment operators such that we don't need
2693// conditional compilation in a lot of places.
2694//
2695// In order to make the representation efficient, the d'tor of String
2696// is not virtual.  Therefore DO NOT INHERIT FROM String.
2697class GTEST_API_ String {
2698 public:
2699  // Static utility methods
2700
2701  // Returns the input enclosed in double quotes if it's not NULL;
2702  // otherwise returns "(null)".  For example, "\"Hello\"" is returned
2703  // for input "Hello".
2704  //
2705  // This is useful for printing a C string in the syntax of a literal.
2706  //
2707  // Known issue: escape sequences are not handled yet.
2708  static String ShowCStringQuoted(const char* c_str);
2709
2710  // Clones a 0-terminated C string, allocating memory using new.  The
2711  // caller is responsible for deleting the return value using
2712  // delete[].  Returns the cloned string, or NULL if the input is
2713  // NULL.
2714  //
2715  // This is different from strdup() in string.h, which allocates
2716  // memory using malloc().
2717  static const char* CloneCString(const char* c_str);
2718
2719#if GTEST_OS_WINDOWS_MOBILE
2720  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be
2721  // able to pass strings to Win32 APIs on CE we need to convert them
2722  // to 'Unicode', UTF-16.
2723
2724  // Creates a UTF-16 wide string from the given ANSI string, allocating
2725  // memory using new. The caller is responsible for deleting the return
2726  // value using delete[]. Returns the wide string, or NULL if the
2727  // input is NULL.
2728  //
2729  // The wide string is created using the ANSI codepage (CP_ACP) to
2730  // match the behaviour of the ANSI versions of Win32 calls and the
2731  // C runtime.
2732  static LPCWSTR AnsiToUtf16(const char* c_str);
2733
2734  // Creates an ANSI string from the given wide string, allocating
2735  // memory using new. The caller is responsible for deleting the return
2736  // value using delete[]. Returns the ANSI string, or NULL if the
2737  // input is NULL.
2738  //
2739  // The returned string is created using the ANSI codepage (CP_ACP) to
2740  // match the behaviour of the ANSI versions of Win32 calls and the
2741  // C runtime.
2742  static const char* Utf16ToAnsi(LPCWSTR utf16_str);
2743#endif
2744
2745  // Compares two C strings.  Returns true iff they have the same content.
2746  //
2747  // Unlike strcmp(), this function can handle NULL argument(s).  A
2748  // NULL C string is considered different to any non-NULL C string,
2749  // including the empty string.
2750  static bool CStringEquals(const char* lhs, const char* rhs);
2751
2752  // Converts a wide C string to a String using the UTF-8 encoding.
2753  // NULL will be converted to "(null)".  If an error occurred during
2754  // the conversion, "(failed to convert from wide string)" is
2755  // returned.
2756  static String ShowWideCString(const wchar_t* wide_c_str);
2757
2758  // Similar to ShowWideCString(), except that this function encloses
2759  // the converted string in double quotes.
2760  static String ShowWideCStringQuoted(const wchar_t* wide_c_str);
2761
2762  // Compares two wide C strings.  Returns true iff they have the same
2763  // content.
2764  //
2765  // Unlike wcscmp(), this function can handle NULL argument(s).  A
2766  // NULL C string is considered different to any non-NULL C string,
2767  // including the empty string.
2768  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);
2769
2770  // Compares two C strings, ignoring case.  Returns true iff they
2771  // have the same content.
2772  //
2773  // Unlike strcasecmp(), this function can handle NULL argument(s).
2774  // A NULL C string is considered different to any non-NULL C string,
2775  // including the empty string.
2776  static bool CaseInsensitiveCStringEquals(const char* lhs,
2777                                           const char* rhs);
2778
2779  // Compares two wide C strings, ignoring case.  Returns true iff they
2780  // have the same content.
2781  //
2782  // Unlike wcscasecmp(), this function can handle NULL argument(s).
2783  // A NULL C string is considered different to any non-NULL wide C string,
2784  // including the empty string.
2785  // NB: The implementations on different platforms slightly differ.
2786  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE
2787  // environment variable. On GNU platform this method uses wcscasecmp
2788  // which compares according to LC_CTYPE category of the current locale.
2789  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
2790  // current locale.
2791  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
2792                                               const wchar_t* rhs);
2793
2794  // Formats a list of arguments to a String, using the same format
2795  // spec string as for printf.
2796  //
2797  // We do not use the StringPrintf class as it is not universally
2798  // available.
2799  //
2800  // The result is limited to 4096 characters (including the tailing
2801  // 0).  If 4096 characters are not enough to format the input,
2802  // "<buffer exceeded>" is returned.
2803  static String Format(const char* format, ...);
2804
2805  // C'tors
2806
2807  // The default c'tor constructs a NULL string.
2808  String() : c_str_(NULL), length_(0) {}
2809
2810  // Constructs a String by cloning a 0-terminated C string.
2811  String(const char* a_c_str) {  // NOLINT
2812    if (a_c_str == NULL) {
2813      c_str_ = NULL;
2814      length_ = 0;
2815    } else {
2816      ConstructNonNull(a_c_str, strlen(a_c_str));
2817    }
2818  }
2819
2820  // Constructs a String by copying a given number of chars from a
2821  // buffer.  E.g. String("hello", 3) creates the string "hel",
2822  // String("a\0bcd", 4) creates "a\0bc", String(NULL, 0) creates "",
2823  // and String(NULL, 1) results in access violation.
2824  String(const char* buffer, size_t a_length) {
2825    ConstructNonNull(buffer, a_length);
2826  }
2827
2828  // The copy c'tor creates a new copy of the string.  The two
2829  // String objects do not share content.
2830  String(const String& str) : c_str_(NULL), length_(0) { *this = str; }
2831
2832  // D'tor.  String is intended to be a final class, so the d'tor
2833  // doesn't need to be virtual.
2834  ~String() { delete[] c_str_; }
2835
2836  // Allows a String to be implicitly converted to an ::std::string or
2837  // ::string, and vice versa.  Converting a String containing a NULL
2838  // pointer to ::std::string or ::string is undefined behavior.
2839  // Converting a ::std::string or ::string containing an embedded NUL
2840  // character to a String will result in the prefix up to the first
2841  // NUL character.
2842  String(const ::std::string& str) {
2843    ConstructNonNull(str.c_str(), str.length());
2844  }
2845
2846  operator ::std::string() const { return ::std::string(c_str(), length()); }
2847
2848#if GTEST_HAS_GLOBAL_STRING
2849  String(const ::string& str) {
2850    ConstructNonNull(str.c_str(), str.length());
2851  }
2852
2853  operator ::string() const { return ::string(c_str(), length()); }
2854#endif  // GTEST_HAS_GLOBAL_STRING
2855
2856  // Returns true iff this is an empty string (i.e. "").
2857  bool empty() const { return (c_str() != NULL) && (length() == 0); }
2858
2859  // Compares this with another String.
2860  // Returns < 0 if this is less than rhs, 0 if this is equal to rhs, or > 0
2861  // if this is greater than rhs.
2862  int Compare(const String& rhs) const;
2863
2864  // Returns true iff this String equals the given C string.  A NULL
2865  // string and a non-NULL string are considered not equal.
2866  bool operator==(const char* a_c_str) const { return Compare(a_c_str) == 0; }
2867
2868  // Returns true iff this String is less than the given String.  A
2869  // NULL string is considered less than "".
2870  bool operator<(const String& rhs) const { return Compare(rhs) < 0; }
2871
2872  // Returns true iff this String doesn't equal the given C string.  A NULL
2873  // string and a non-NULL string are considered not equal.
2874  bool operator!=(const char* a_c_str) const { return !(*this == a_c_str); }
2875
2876  // Returns true iff this String ends with the given suffix.  *Any*
2877  // String is considered to end with a NULL or empty suffix.
2878  bool EndsWith(const char* suffix) const;
2879
2880  // Returns true iff this String ends with the given suffix, not considering
2881  // case. Any String is considered to end with a NULL or empty suffix.
2882  bool EndsWithCaseInsensitive(const char* suffix) const;
2883
2884  // Returns the length of the encapsulated string, or 0 if the
2885  // string is NULL.
2886  size_t length() const { return length_; }
2887
2888  // Gets the 0-terminated C string this String object represents.
2889  // The String object still owns the string.  Therefore the caller
2890  // should NOT delete the return value.
2891  const char* c_str() const { return c_str_; }
2892
2893  // Assigns a C string to this object.  Self-assignment works.
2894  const String& operator=(const char* a_c_str) {
2895    return *this = String(a_c_str);
2896  }
2897
2898  // Assigns a String object to this object.  Self-assignment works.
2899  const String& operator=(const String& rhs) {
2900    if (this != &rhs) {
2901      delete[] c_str_;
2902      if (rhs.c_str() == NULL) {
2903        c_str_ = NULL;
2904        length_ = 0;
2905      } else {
2906        ConstructNonNull(rhs.c_str(), rhs.length());
2907      }
2908    }
2909
2910    return *this;
2911  }
2912
2913 private:
2914  // Constructs a non-NULL String from the given content.  This
2915  // function can only be called when data_ has not been allocated.
2916  // ConstructNonNull(NULL, 0) results in an empty string ("").
2917  // ConstructNonNull(NULL, non_zero) is undefined behavior.
2918  void ConstructNonNull(const char* buffer, size_t a_length) {
2919    char* const str = new char[a_length + 1];
2920    memcpy(str, buffer, a_length);
2921    str[a_length] = '\0';
2922    c_str_ = str;
2923    length_ = a_length;
2924  }
2925
2926  const char* c_str_;
2927  size_t length_;
2928};  // class String
2929
2930// Streams a String to an ostream.  Each '\0' character in the String
2931// is replaced with "\\0".
2932inline ::std::ostream& operator<<(::std::ostream& os, const String& str) {
2933  if (str.c_str() == NULL) {
2934    os << "(null)";
2935  } else {
2936    const char* const c_str = str.c_str();
2937    for (size_t i = 0; i != str.length(); i++) {
2938      if (c_str[i] == '\0') {
2939        os << "\\0";
2940      } else {
2941        os << c_str[i];
2942      }
2943    }
2944  }
2945  return os;
2946}
2947
2948// Gets the content of the StrStream's buffer as a String.  Each '\0'
2949// character in the buffer is replaced with "\\0".
2950GTEST_API_ String StrStreamToString(StrStream* stream);
2951
2952// Converts a streamable value to a String.  A NULL pointer is
2953// converted to "(null)".  When the input value is a ::string,
2954// ::std::string, ::wstring, or ::std::wstring object, each NUL
2955// character in it is replaced with "\\0".
2956
2957// Declared here but defined in gtest.h, so that it has access
2958// to the definition of the Message class, required by the ARM
2959// compiler.
2960template <typename T>
2961String StreamableToString(const T& streamable);
2962
2963}  // namespace internal
2964}  // namespace testing
2965
2966#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_
2967// Copyright 2008, Google Inc.
2968// All rights reserved.
2969//
2970// Redistribution and use in source and binary forms, with or without
2971// modification, are permitted provided that the following conditions are
2972// met:
2973//
2974//     * Redistributions of source code must retain the above copyright
2975// notice, this list of conditions and the following disclaimer.
2976//     * Redistributions in binary form must reproduce the above
2977// copyright notice, this list of conditions and the following disclaimer
2978// in the documentation and/or other materials provided with the
2979// distribution.
2980//     * Neither the name of Google Inc. nor the names of its
2981// contributors may be used to endorse or promote products derived from
2982// this software without specific prior written permission.
2983//
2984// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2985// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2986// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2987// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2988// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2989// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2990// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2991// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2992// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2993// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2994// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2995//
2996// Author: keith.ray@gmail.com (Keith Ray)
2997//
2998// Google Test filepath utilities
2999//
3000// This header file declares classes and functions used internally by
3001// Google Test.  They are subject to change without notice.
3002//
3003// This file is #included in <gtest/internal/gtest-internal.h>.
3004// Do not include this header file separately!
3005
3006#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
3007#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
3008
3009
3010namespace testing {
3011namespace internal {
3012
3013// FilePath - a class for file and directory pathname manipulation which
3014// handles platform-specific conventions (like the pathname separator).
3015// Used for helper functions for naming files in a directory for xml output.
3016// Except for Set methods, all methods are const or static, which provides an
3017// "immutable value object" -- useful for peace of mind.
3018// A FilePath with a value ending in a path separator ("like/this/") represents
3019// a directory, otherwise it is assumed to represent a file. In either case,
3020// it may or may not represent an actual file or directory in the file system.
3021// Names are NOT checked for syntax correctness -- no checking for illegal
3022// characters, malformed paths, etc.
3023
3024class GTEST_API_ FilePath {
3025 public:
3026  FilePath() : pathname_("") { }
3027  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }
3028
3029  explicit FilePath(const char* pathname) : pathname_(pathname) {
3030    Normalize();
3031  }
3032
3033  explicit FilePath(const String& pathname) : pathname_(pathname) {
3034    Normalize();
3035  }
3036
3037  FilePath& operator=(const FilePath& rhs) {
3038    Set(rhs);
3039    return *this;
3040  }
3041
3042  void Set(const FilePath& rhs) {
3043    pathname_ = rhs.pathname_;
3044  }
3045
3046  String ToString() const { return pathname_; }
3047  const char* c_str() const { return pathname_.c_str(); }
3048
3049  // Returns the current working directory, or "" if unsuccessful.
3050  static FilePath GetCurrentDir();
3051
3052  // Given directory = "dir", base_name = "test", number = 0,
3053  // extension = "xml", returns "dir/test.xml". If number is greater
3054  // than zero (e.g., 12), returns "dir/test_12.xml".
3055  // On Windows platform, uses \ as the separator rather than /.
3056  static FilePath MakeFileName(const FilePath& directory,
3057                               const FilePath& base_name,
3058                               int number,
3059                               const char* extension);
3060
3061  // Given directory = "dir", relative_path = "test.xml",
3062  // returns "dir/test.xml".
3063  // On Windows, uses \ as the separator rather than /.
3064  static FilePath ConcatPaths(const FilePath& directory,
3065                              const FilePath& relative_path);
3066
3067  // Returns a pathname for a file that does not currently exist. The pathname
3068  // will be directory/base_name.extension or
3069  // directory/base_name_<number>.extension if directory/base_name.extension
3070  // already exists. The number will be incremented until a pathname is found
3071  // that does not already exist.
3072  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.
3073  // There could be a race condition if two or more processes are calling this
3074  // function at the same time -- they could both pick the same filename.
3075  static FilePath GenerateUniqueFileName(const FilePath& directory,
3076                                         const FilePath& base_name,
3077                                         const char* extension);
3078
3079  // Returns true iff the path is NULL or "".
3080  bool IsEmpty() const { return c_str() == NULL || *c_str() == '\0'; }
3081
3082  // If input name has a trailing separator character, removes it and returns
3083  // the name, otherwise return the name string unmodified.
3084  // On Windows platform, uses \ as the separator, other platforms use /.
3085  FilePath RemoveTrailingPathSeparator() const;
3086
3087  // Returns a copy of the FilePath with the directory part removed.
3088  // Example: FilePath("path/to/file").RemoveDirectoryName() returns
3089  // FilePath("file"). If there is no directory part ("just_a_file"), it returns
3090  // the FilePath unmodified. If there is no file part ("just_a_dir/") it
3091  // returns an empty FilePath ("").
3092  // On Windows platform, '\' is the path separator, otherwise it is '/'.
3093  FilePath RemoveDirectoryName() const;
3094
3095  // RemoveFileName returns the directory path with the filename removed.
3096  // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/".
3097  // If the FilePath is "a_file" or "/a_file", RemoveFileName returns
3098  // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does
3099  // not have a file, like "just/a/dir/", it returns the FilePath unmodified.
3100  // On Windows platform, '\' is the path separator, otherwise it is '/'.
3101  FilePath RemoveFileName() const;
3102
3103  // Returns a copy of the FilePath with the case-insensitive extension removed.
3104  // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns
3105  // FilePath("dir/file"). If a case-insensitive extension is not
3106  // found, returns a copy of the original FilePath.
3107  FilePath RemoveExtension(const char* extension) const;
3108
3109  // Creates directories so that path exists. Returns true if successful or if
3110  // the directories already exist; returns false if unable to create
3111  // directories for any reason. Will also return false if the FilePath does
3112  // not represent a directory (that is, it doesn't end with a path separator).
3113  bool CreateDirectoriesRecursively() const;
3114
3115  // Create the directory so that path exists. Returns true if successful or
3116  // if the directory already exists; returns false if unable to create the
3117  // directory for any reason, including if the parent directory does not
3118  // exist. Not named "CreateDirectory" because that's a macro on Windows.
3119  bool CreateFolder() const;
3120
3121  // Returns true if FilePath describes something in the file-system,
3122  // either a file, directory, or whatever, and that something exists.
3123  bool FileOrDirectoryExists() const;
3124
3125  // Returns true if pathname describes a directory in the file-system
3126  // that exists.
3127  bool DirectoryExists() const;
3128
3129  // Returns true if FilePath ends with a path separator, which indicates that
3130  // it is intended to represent a directory. Returns false otherwise.
3131  // This does NOT check that a directory (or file) actually exists.
3132  bool IsDirectory() const;
3133
3134  // Returns true if pathname describes a root directory. (Windows has one
3135  // root directory per disk drive.)
3136  bool IsRootDirectory() const;
3137
3138  // Returns true if pathname describes an absolute path.
3139  bool IsAbsolutePath() const;
3140
3141 private:
3142  // Replaces multiple consecutive separators with a single separator.
3143  // For example, "bar///foo" becomes "bar/foo". Does not eliminate other
3144  // redundancies that might be in a pathname involving "." or "..".
3145  //
3146  // A pathname with multiple consecutive separators may occur either through
3147  // user error or as a result of some scripts or APIs that generate a pathname
3148  // with a trailing separator. On other platforms the same API or script
3149  // may NOT generate a pathname with a trailing "/". Then elsewhere that
3150  // pathname may have another "/" and pathname components added to it,
3151  // without checking for the separator already being there.
3152  // The script language and operating system may allow paths like "foo//bar"
3153  // but some of the functions in FilePath will not handle that correctly. In
3154  // particular, RemoveTrailingPathSeparator() only removes one separator, and
3155  // it is called in CreateDirectoriesRecursively() assuming that it will change
3156  // a pathname from directory syntax (trailing separator) to filename syntax.
3157  //
3158  // On Windows this method also replaces the alternate path separator '/' with
3159  // the primary path separator '\\', so that for example "bar\\/\\foo" becomes
3160  // "bar\\foo".
3161
3162  void Normalize();
3163
3164  // Returns a pointer to the last occurence of a valid path separator in
3165  // the FilePath. On Windows, for example, both '/' and '\' are valid path
3166  // separators. Returns NULL if no path separator was found.
3167  const char* FindLastPathSeparator() const;
3168
3169  String pathname_;
3170};  // class FilePath
3171
3172}  // namespace internal
3173}  // namespace testing
3174
3175#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_
3176// This file was GENERATED by command:
3177//     pump.py gtest-type-util.h.pump
3178// DO NOT EDIT BY HAND!!!
3179
3180// Copyright 2008 Google Inc.
3181// All Rights Reserved.
3182//
3183// Redistribution and use in source and binary forms, with or without
3184// modification, are permitted provided that the following conditions are
3185// met:
3186//
3187//     * Redistributions of source code must retain the above copyright
3188// notice, this list of conditions and the following disclaimer.
3189//     * Redistributions in binary form must reproduce the above
3190// copyright notice, this list of conditions and the following disclaimer
3191// in the documentation and/or other materials provided with the
3192// distribution.
3193//     * Neither the name of Google Inc. nor the names of its
3194// contributors may be used to endorse or promote products derived from
3195// this software without specific prior written permission.
3196//
3197// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3198// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3199// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3200// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3201// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3202// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3203// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3204// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3205// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3206// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3207// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3208//
3209// Author: wan@google.com (Zhanyong Wan)
3210
3211// Type utilities needed for implementing typed and type-parameterized
3212// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!
3213//
3214// Currently we support at most 50 types in a list, and at most 50
3215// type-parameterized tests in one type-parameterized test case.
3216// Please contact googletestframework@googlegroups.com if you need
3217// more.
3218
3219#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3220#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_
3221
3222
3223#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
3224
3225// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using
3226// libstdc++ (which is where cxxabi.h comes from).
3227#ifdef __GLIBCXX__
3228#include <cxxabi.h>
3229#endif  // __GLIBCXX__
3230
3231namespace testing {
3232namespace internal {
3233
3234// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same
3235// type.  This can be used as a compile-time assertion to ensure that
3236// two types are equal.
3237
3238template <typename T1, typename T2>
3239struct AssertTypeEq;
3240
3241template <typename T>
3242struct AssertTypeEq<T, T> {
3243  typedef bool type;
3244};
3245
3246// GetTypeName<T>() returns a human-readable name of type T.
3247template <typename T>
3248String GetTypeName() {
3249#if GTEST_HAS_RTTI
3250
3251  const char* const name = typeid(T).name();
3252#ifdef __GLIBCXX__
3253  int status = 0;
3254  // gcc's implementation of typeid(T).name() mangles the type name,
3255  // so we have to demangle it.
3256  char* const readable_name = abi::__cxa_demangle(name, 0, 0, &status);
3257  const String name_str(status == 0 ? readable_name : name);
3258  free(readable_name);
3259  return name_str;
3260#else
3261  return name;
3262#endif  // __GLIBCXX__
3263
3264#else
3265  return "<type>";
3266#endif  // GTEST_HAS_RTTI
3267}
3268
3269// A unique type used as the default value for the arguments of class
3270// template Types.  This allows us to simulate variadic templates
3271// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't
3272// support directly.
3273struct None {};
3274
3275// The following family of struct and struct templates are used to
3276// represent type lists.  In particular, TypesN<T1, T2, ..., TN>
3277// represents a type list with N types (T1, T2, ..., and TN) in it.
3278// Except for Types0, every struct in the family has two member types:
3279// Head for the first type in the list, and Tail for the rest of the
3280// list.
3281
3282// The empty type list.
3283struct Types0 {};
3284
3285// Type lists of length 1, 2, 3, and so on.
3286
3287template <typename T1>
3288struct Types1 {
3289  typedef T1 Head;
3290  typedef Types0 Tail;
3291};
3292template <typename T1, typename T2>
3293struct Types2 {
3294  typedef T1 Head;
3295  typedef Types1<T2> Tail;
3296};
3297
3298template <typename T1, typename T2, typename T3>
3299struct Types3 {
3300  typedef T1 Head;
3301  typedef Types2<T2, T3> Tail;
3302};
3303
3304template <typename T1, typename T2, typename T3, typename T4>
3305struct Types4 {
3306  typedef T1 Head;
3307  typedef Types3<T2, T3, T4> Tail;
3308};
3309
3310template <typename T1, typename T2, typename T3, typename T4, typename T5>
3311struct Types5 {
3312  typedef T1 Head;
3313  typedef Types4<T2, T3, T4, T5> Tail;
3314};
3315
3316template <typename T1, typename T2, typename T3, typename T4, typename T5,
3317    typename T6>
3318struct Types6 {
3319  typedef T1 Head;
3320  typedef Types5<T2, T3, T4, T5, T6> Tail;
3321};
3322
3323template <typename T1, typename T2, typename T3, typename T4, typename T5,
3324    typename T6, typename T7>
3325struct Types7 {
3326  typedef T1 Head;
3327  typedef Types6<T2, T3, T4, T5, T6, T7> Tail;
3328};
3329
3330template <typename T1, typename T2, typename T3, typename T4, typename T5,
3331    typename T6, typename T7, typename T8>
3332struct Types8 {
3333  typedef T1 Head;
3334  typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;
3335};
3336
3337template <typename T1, typename T2, typename T3, typename T4, typename T5,
3338    typename T6, typename T7, typename T8, typename T9>
3339struct Types9 {
3340  typedef T1 Head;
3341  typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;
3342};
3343
3344template <typename T1, typename T2, typename T3, typename T4, typename T5,
3345    typename T6, typename T7, typename T8, typename T9, typename T10>
3346struct Types10 {
3347  typedef T1 Head;
3348  typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;
3349};
3350
3351template <typename T1, typename T2, typename T3, typename T4, typename T5,
3352    typename T6, typename T7, typename T8, typename T9, typename T10,
3353    typename T11>
3354struct Types11 {
3355  typedef T1 Head;
3356  typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;
3357};
3358
3359template <typename T1, typename T2, typename T3, typename T4, typename T5,
3360    typename T6, typename T7, typename T8, typename T9, typename T10,
3361    typename T11, typename T12>
3362struct Types12 {
3363  typedef T1 Head;
3364  typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;
3365};
3366
3367template <typename T1, typename T2, typename T3, typename T4, typename T5,
3368    typename T6, typename T7, typename T8, typename T9, typename T10,
3369    typename T11, typename T12, typename T13>
3370struct Types13 {
3371  typedef T1 Head;
3372  typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;
3373};
3374
3375template <typename T1, typename T2, typename T3, typename T4, typename T5,
3376    typename T6, typename T7, typename T8, typename T9, typename T10,
3377    typename T11, typename T12, typename T13, typename T14>
3378struct Types14 {
3379  typedef T1 Head;
3380  typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;
3381};
3382
3383template <typename T1, typename T2, typename T3, typename T4, typename T5,
3384    typename T6, typename T7, typename T8, typename T9, typename T10,
3385    typename T11, typename T12, typename T13, typename T14, typename T15>
3386struct Types15 {
3387  typedef T1 Head;
3388  typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
3389      T15> Tail;
3390};
3391
3392template <typename T1, typename T2, typename T3, typename T4, typename T5,
3393    typename T6, typename T7, typename T8, typename T9, typename T10,
3394    typename T11, typename T12, typename T13, typename T14, typename T15,
3395    typename T16>
3396struct Types16 {
3397  typedef T1 Head;
3398  typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3399      T16> Tail;
3400};
3401
3402template <typename T1, typename T2, typename T3, typename T4, typename T5,
3403    typename T6, typename T7, typename T8, typename T9, typename T10,
3404    typename T11, typename T12, typename T13, typename T14, typename T15,
3405    typename T16, typename T17>
3406struct Types17 {
3407  typedef T1 Head;
3408  typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3409      T16, T17> Tail;
3410};
3411
3412template <typename T1, typename T2, typename T3, typename T4, typename T5,
3413    typename T6, typename T7, typename T8, typename T9, typename T10,
3414    typename T11, typename T12, typename T13, typename T14, typename T15,
3415    typename T16, typename T17, typename T18>
3416struct Types18 {
3417  typedef T1 Head;
3418  typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3419      T16, T17, T18> Tail;
3420};
3421
3422template <typename T1, typename T2, typename T3, typename T4, typename T5,
3423    typename T6, typename T7, typename T8, typename T9, typename T10,
3424    typename T11, typename T12, typename T13, typename T14, typename T15,
3425    typename T16, typename T17, typename T18, typename T19>
3426struct Types19 {
3427  typedef T1 Head;
3428  typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3429      T16, T17, T18, T19> Tail;
3430};
3431
3432template <typename T1, typename T2, typename T3, typename T4, typename T5,
3433    typename T6, typename T7, typename T8, typename T9, typename T10,
3434    typename T11, typename T12, typename T13, typename T14, typename T15,
3435    typename T16, typename T17, typename T18, typename T19, typename T20>
3436struct Types20 {
3437  typedef T1 Head;
3438  typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3439      T16, T17, T18, T19, T20> Tail;
3440};
3441
3442template <typename T1, typename T2, typename T3, typename T4, typename T5,
3443    typename T6, typename T7, typename T8, typename T9, typename T10,
3444    typename T11, typename T12, typename T13, typename T14, typename T15,
3445    typename T16, typename T17, typename T18, typename T19, typename T20,
3446    typename T21>
3447struct Types21 {
3448  typedef T1 Head;
3449  typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3450      T16, T17, T18, T19, T20, T21> Tail;
3451};
3452
3453template <typename T1, typename T2, typename T3, typename T4, typename T5,
3454    typename T6, typename T7, typename T8, typename T9, typename T10,
3455    typename T11, typename T12, typename T13, typename T14, typename T15,
3456    typename T16, typename T17, typename T18, typename T19, typename T20,
3457    typename T21, typename T22>
3458struct Types22 {
3459  typedef T1 Head;
3460  typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3461      T16, T17, T18, T19, T20, T21, T22> Tail;
3462};
3463
3464template <typename T1, typename T2, typename T3, typename T4, typename T5,
3465    typename T6, typename T7, typename T8, typename T9, typename T10,
3466    typename T11, typename T12, typename T13, typename T14, typename T15,
3467    typename T16, typename T17, typename T18, typename T19, typename T20,
3468    typename T21, typename T22, typename T23>
3469struct Types23 {
3470  typedef T1 Head;
3471  typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3472      T16, T17, T18, T19, T20, T21, T22, T23> Tail;
3473};
3474
3475template <typename T1, typename T2, typename T3, typename T4, typename T5,
3476    typename T6, typename T7, typename T8, typename T9, typename T10,
3477    typename T11, typename T12, typename T13, typename T14, typename T15,
3478    typename T16, typename T17, typename T18, typename T19, typename T20,
3479    typename T21, typename T22, typename T23, typename T24>
3480struct Types24 {
3481  typedef T1 Head;
3482  typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3483      T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;
3484};
3485
3486template <typename T1, typename T2, typename T3, typename T4, typename T5,
3487    typename T6, typename T7, typename T8, typename T9, typename T10,
3488    typename T11, typename T12, typename T13, typename T14, typename T15,
3489    typename T16, typename T17, typename T18, typename T19, typename T20,
3490    typename T21, typename T22, typename T23, typename T24, typename T25>
3491struct Types25 {
3492  typedef T1 Head;
3493  typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3494      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;
3495};
3496
3497template <typename T1, typename T2, typename T3, typename T4, typename T5,
3498    typename T6, typename T7, typename T8, typename T9, typename T10,
3499    typename T11, typename T12, typename T13, typename T14, typename T15,
3500    typename T16, typename T17, typename T18, typename T19, typename T20,
3501    typename T21, typename T22, typename T23, typename T24, typename T25,
3502    typename T26>
3503struct Types26 {
3504  typedef T1 Head;
3505  typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3506      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;
3507};
3508
3509template <typename T1, typename T2, typename T3, typename T4, typename T5,
3510    typename T6, typename T7, typename T8, typename T9, typename T10,
3511    typename T11, typename T12, typename T13, typename T14, typename T15,
3512    typename T16, typename T17, typename T18, typename T19, typename T20,
3513    typename T21, typename T22, typename T23, typename T24, typename T25,
3514    typename T26, typename T27>
3515struct Types27 {
3516  typedef T1 Head;
3517  typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3518      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;
3519};
3520
3521template <typename T1, typename T2, typename T3, typename T4, typename T5,
3522    typename T6, typename T7, typename T8, typename T9, typename T10,
3523    typename T11, typename T12, typename T13, typename T14, typename T15,
3524    typename T16, typename T17, typename T18, typename T19, typename T20,
3525    typename T21, typename T22, typename T23, typename T24, typename T25,
3526    typename T26, typename T27, typename T28>
3527struct Types28 {
3528  typedef T1 Head;
3529  typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3530      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;
3531};
3532
3533template <typename T1, typename T2, typename T3, typename T4, typename T5,
3534    typename T6, typename T7, typename T8, typename T9, typename T10,
3535    typename T11, typename T12, typename T13, typename T14, typename T15,
3536    typename T16, typename T17, typename T18, typename T19, typename T20,
3537    typename T21, typename T22, typename T23, typename T24, typename T25,
3538    typename T26, typename T27, typename T28, typename T29>
3539struct Types29 {
3540  typedef T1 Head;
3541  typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3542      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,
3543      T29> Tail;
3544};
3545
3546template <typename T1, typename T2, typename T3, typename T4, typename T5,
3547    typename T6, typename T7, typename T8, typename T9, typename T10,
3548    typename T11, typename T12, typename T13, typename T14, typename T15,
3549    typename T16, typename T17, typename T18, typename T19, typename T20,
3550    typename T21, typename T22, typename T23, typename T24, typename T25,
3551    typename T26, typename T27, typename T28, typename T29, typename T30>
3552struct Types30 {
3553  typedef T1 Head;
3554  typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3555      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3556      T30> Tail;
3557};
3558
3559template <typename T1, typename T2, typename T3, typename T4, typename T5,
3560    typename T6, typename T7, typename T8, typename T9, typename T10,
3561    typename T11, typename T12, typename T13, typename T14, typename T15,
3562    typename T16, typename T17, typename T18, typename T19, typename T20,
3563    typename T21, typename T22, typename T23, typename T24, typename T25,
3564    typename T26, typename T27, typename T28, typename T29, typename T30,
3565    typename T31>
3566struct Types31 {
3567  typedef T1 Head;
3568  typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3569      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3570      T30, T31> Tail;
3571};
3572
3573template <typename T1, typename T2, typename T3, typename T4, typename T5,
3574    typename T6, typename T7, typename T8, typename T9, typename T10,
3575    typename T11, typename T12, typename T13, typename T14, typename T15,
3576    typename T16, typename T17, typename T18, typename T19, typename T20,
3577    typename T21, typename T22, typename T23, typename T24, typename T25,
3578    typename T26, typename T27, typename T28, typename T29, typename T30,
3579    typename T31, typename T32>
3580struct Types32 {
3581  typedef T1 Head;
3582  typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3583      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3584      T30, T31, T32> Tail;
3585};
3586
3587template <typename T1, typename T2, typename T3, typename T4, typename T5,
3588    typename T6, typename T7, typename T8, typename T9, typename T10,
3589    typename T11, typename T12, typename T13, typename T14, typename T15,
3590    typename T16, typename T17, typename T18, typename T19, typename T20,
3591    typename T21, typename T22, typename T23, typename T24, typename T25,
3592    typename T26, typename T27, typename T28, typename T29, typename T30,
3593    typename T31, typename T32, typename T33>
3594struct Types33 {
3595  typedef T1 Head;
3596  typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3597      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3598      T30, T31, T32, T33> Tail;
3599};
3600
3601template <typename T1, typename T2, typename T3, typename T4, typename T5,
3602    typename T6, typename T7, typename T8, typename T9, typename T10,
3603    typename T11, typename T12, typename T13, typename T14, typename T15,
3604    typename T16, typename T17, typename T18, typename T19, typename T20,
3605    typename T21, typename T22, typename T23, typename T24, typename T25,
3606    typename T26, typename T27, typename T28, typename T29, typename T30,
3607    typename T31, typename T32, typename T33, typename T34>
3608struct Types34 {
3609  typedef T1 Head;
3610  typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3611      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3612      T30, T31, T32, T33, T34> Tail;
3613};
3614
3615template <typename T1, typename T2, typename T3, typename T4, typename T5,
3616    typename T6, typename T7, typename T8, typename T9, typename T10,
3617    typename T11, typename T12, typename T13, typename T14, typename T15,
3618    typename T16, typename T17, typename T18, typename T19, typename T20,
3619    typename T21, typename T22, typename T23, typename T24, typename T25,
3620    typename T26, typename T27, typename T28, typename T29, typename T30,
3621    typename T31, typename T32, typename T33, typename T34, typename T35>
3622struct Types35 {
3623  typedef T1 Head;
3624  typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3625      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3626      T30, T31, T32, T33, T34, T35> Tail;
3627};
3628
3629template <typename T1, typename T2, typename T3, typename T4, typename T5,
3630    typename T6, typename T7, typename T8, typename T9, typename T10,
3631    typename T11, typename T12, typename T13, typename T14, typename T15,
3632    typename T16, typename T17, typename T18, typename T19, typename T20,
3633    typename T21, typename T22, typename T23, typename T24, typename T25,
3634    typename T26, typename T27, typename T28, typename T29, typename T30,
3635    typename T31, typename T32, typename T33, typename T34, typename T35,
3636    typename T36>
3637struct Types36 {
3638  typedef T1 Head;
3639  typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3640      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3641      T30, T31, T32, T33, T34, T35, T36> Tail;
3642};
3643
3644template <typename T1, typename T2, typename T3, typename T4, typename T5,
3645    typename T6, typename T7, typename T8, typename T9, typename T10,
3646    typename T11, typename T12, typename T13, typename T14, typename T15,
3647    typename T16, typename T17, typename T18, typename T19, typename T20,
3648    typename T21, typename T22, typename T23, typename T24, typename T25,
3649    typename T26, typename T27, typename T28, typename T29, typename T30,
3650    typename T31, typename T32, typename T33, typename T34, typename T35,
3651    typename T36, typename T37>
3652struct Types37 {
3653  typedef T1 Head;
3654  typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3655      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3656      T30, T31, T32, T33, T34, T35, T36, T37> Tail;
3657};
3658
3659template <typename T1, typename T2, typename T3, typename T4, typename T5,
3660    typename T6, typename T7, typename T8, typename T9, typename T10,
3661    typename T11, typename T12, typename T13, typename T14, typename T15,
3662    typename T16, typename T17, typename T18, typename T19, typename T20,
3663    typename T21, typename T22, typename T23, typename T24, typename T25,
3664    typename T26, typename T27, typename T28, typename T29, typename T30,
3665    typename T31, typename T32, typename T33, typename T34, typename T35,
3666    typename T36, typename T37, typename T38>
3667struct Types38 {
3668  typedef T1 Head;
3669  typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3670      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3671      T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;
3672};
3673
3674template <typename T1, typename T2, typename T3, typename T4, typename T5,
3675    typename T6, typename T7, typename T8, typename T9, typename T10,
3676    typename T11, typename T12, typename T13, typename T14, typename T15,
3677    typename T16, typename T17, typename T18, typename T19, typename T20,
3678    typename T21, typename T22, typename T23, typename T24, typename T25,
3679    typename T26, typename T27, typename T28, typename T29, typename T30,
3680    typename T31, typename T32, typename T33, typename T34, typename T35,
3681    typename T36, typename T37, typename T38, typename T39>
3682struct Types39 {
3683  typedef T1 Head;
3684  typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3685      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3686      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;
3687};
3688
3689template <typename T1, typename T2, typename T3, typename T4, typename T5,
3690    typename T6, typename T7, typename T8, typename T9, typename T10,
3691    typename T11, typename T12, typename T13, typename T14, typename T15,
3692    typename T16, typename T17, typename T18, typename T19, typename T20,
3693    typename T21, typename T22, typename T23, typename T24, typename T25,
3694    typename T26, typename T27, typename T28, typename T29, typename T30,
3695    typename T31, typename T32, typename T33, typename T34, typename T35,
3696    typename T36, typename T37, typename T38, typename T39, typename T40>
3697struct Types40 {
3698  typedef T1 Head;
3699  typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3700      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3701      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;
3702};
3703
3704template <typename T1, typename T2, typename T3, typename T4, typename T5,
3705    typename T6, typename T7, typename T8, typename T9, typename T10,
3706    typename T11, typename T12, typename T13, typename T14, typename T15,
3707    typename T16, typename T17, typename T18, typename T19, typename T20,
3708    typename T21, typename T22, typename T23, typename T24, typename T25,
3709    typename T26, typename T27, typename T28, typename T29, typename T30,
3710    typename T31, typename T32, typename T33, typename T34, typename T35,
3711    typename T36, typename T37, typename T38, typename T39, typename T40,
3712    typename T41>
3713struct Types41 {
3714  typedef T1 Head;
3715  typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3716      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3717      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;
3718};
3719
3720template <typename T1, typename T2, typename T3, typename T4, typename T5,
3721    typename T6, typename T7, typename T8, typename T9, typename T10,
3722    typename T11, typename T12, typename T13, typename T14, typename T15,
3723    typename T16, typename T17, typename T18, typename T19, typename T20,
3724    typename T21, typename T22, typename T23, typename T24, typename T25,
3725    typename T26, typename T27, typename T28, typename T29, typename T30,
3726    typename T31, typename T32, typename T33, typename T34, typename T35,
3727    typename T36, typename T37, typename T38, typename T39, typename T40,
3728    typename T41, typename T42>
3729struct Types42 {
3730  typedef T1 Head;
3731  typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3732      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3733      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;
3734};
3735
3736template <typename T1, typename T2, typename T3, typename T4, typename T5,
3737    typename T6, typename T7, typename T8, typename T9, typename T10,
3738    typename T11, typename T12, typename T13, typename T14, typename T15,
3739    typename T16, typename T17, typename T18, typename T19, typename T20,
3740    typename T21, typename T22, typename T23, typename T24, typename T25,
3741    typename T26, typename T27, typename T28, typename T29, typename T30,
3742    typename T31, typename T32, typename T33, typename T34, typename T35,
3743    typename T36, typename T37, typename T38, typename T39, typename T40,
3744    typename T41, typename T42, typename T43>
3745struct Types43 {
3746  typedef T1 Head;
3747  typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3748      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3749      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,
3750      T43> Tail;
3751};
3752
3753template <typename T1, typename T2, typename T3, typename T4, typename T5,
3754    typename T6, typename T7, typename T8, typename T9, typename T10,
3755    typename T11, typename T12, typename T13, typename T14, typename T15,
3756    typename T16, typename T17, typename T18, typename T19, typename T20,
3757    typename T21, typename T22, typename T23, typename T24, typename T25,
3758    typename T26, typename T27, typename T28, typename T29, typename T30,
3759    typename T31, typename T32, typename T33, typename T34, typename T35,
3760    typename T36, typename T37, typename T38, typename T39, typename T40,
3761    typename T41, typename T42, typename T43, typename T44>
3762struct Types44 {
3763  typedef T1 Head;
3764  typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3765      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3766      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3767      T44> Tail;
3768};
3769
3770template <typename T1, typename T2, typename T3, typename T4, typename T5,
3771    typename T6, typename T7, typename T8, typename T9, typename T10,
3772    typename T11, typename T12, typename T13, typename T14, typename T15,
3773    typename T16, typename T17, typename T18, typename T19, typename T20,
3774    typename T21, typename T22, typename T23, typename T24, typename T25,
3775    typename T26, typename T27, typename T28, typename T29, typename T30,
3776    typename T31, typename T32, typename T33, typename T34, typename T35,
3777    typename T36, typename T37, typename T38, typename T39, typename T40,
3778    typename T41, typename T42, typename T43, typename T44, typename T45>
3779struct Types45 {
3780  typedef T1 Head;
3781  typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3782      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3783      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3784      T44, T45> Tail;
3785};
3786
3787template <typename T1, typename T2, typename T3, typename T4, typename T5,
3788    typename T6, typename T7, typename T8, typename T9, typename T10,
3789    typename T11, typename T12, typename T13, typename T14, typename T15,
3790    typename T16, typename T17, typename T18, typename T19, typename T20,
3791    typename T21, typename T22, typename T23, typename T24, typename T25,
3792    typename T26, typename T27, typename T28, typename T29, typename T30,
3793    typename T31, typename T32, typename T33, typename T34, typename T35,
3794    typename T36, typename T37, typename T38, typename T39, typename T40,
3795    typename T41, typename T42, typename T43, typename T44, typename T45,
3796    typename T46>
3797struct Types46 {
3798  typedef T1 Head;
3799  typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3800      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3801      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3802      T44, T45, T46> Tail;
3803};
3804
3805template <typename T1, typename T2, typename T3, typename T4, typename T5,
3806    typename T6, typename T7, typename T8, typename T9, typename T10,
3807    typename T11, typename T12, typename T13, typename T14, typename T15,
3808    typename T16, typename T17, typename T18, typename T19, typename T20,
3809    typename T21, typename T22, typename T23, typename T24, typename T25,
3810    typename T26, typename T27, typename T28, typename T29, typename T30,
3811    typename T31, typename T32, typename T33, typename T34, typename T35,
3812    typename T36, typename T37, typename T38, typename T39, typename T40,
3813    typename T41, typename T42, typename T43, typename T44, typename T45,
3814    typename T46, typename T47>
3815struct Types47 {
3816  typedef T1 Head;
3817  typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3818      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3819      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3820      T44, T45, T46, T47> Tail;
3821};
3822
3823template <typename T1, typename T2, typename T3, typename T4, typename T5,
3824    typename T6, typename T7, typename T8, typename T9, typename T10,
3825    typename T11, typename T12, typename T13, typename T14, typename T15,
3826    typename T16, typename T17, typename T18, typename T19, typename T20,
3827    typename T21, typename T22, typename T23, typename T24, typename T25,
3828    typename T26, typename T27, typename T28, typename T29, typename T30,
3829    typename T31, typename T32, typename T33, typename T34, typename T35,
3830    typename T36, typename T37, typename T38, typename T39, typename T40,
3831    typename T41, typename T42, typename T43, typename T44, typename T45,
3832    typename T46, typename T47, typename T48>
3833struct Types48 {
3834  typedef T1 Head;
3835  typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3836      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3837      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3838      T44, T45, T46, T47, T48> Tail;
3839};
3840
3841template <typename T1, typename T2, typename T3, typename T4, typename T5,
3842    typename T6, typename T7, typename T8, typename T9, typename T10,
3843    typename T11, typename T12, typename T13, typename T14, typename T15,
3844    typename T16, typename T17, typename T18, typename T19, typename T20,
3845    typename T21, typename T22, typename T23, typename T24, typename T25,
3846    typename T26, typename T27, typename T28, typename T29, typename T30,
3847    typename T31, typename T32, typename T33, typename T34, typename T35,
3848    typename T36, typename T37, typename T38, typename T39, typename T40,
3849    typename T41, typename T42, typename T43, typename T44, typename T45,
3850    typename T46, typename T47, typename T48, typename T49>
3851struct Types49 {
3852  typedef T1 Head;
3853  typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3854      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3855      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3856      T44, T45, T46, T47, T48, T49> Tail;
3857};
3858
3859template <typename T1, typename T2, typename T3, typename T4, typename T5,
3860    typename T6, typename T7, typename T8, typename T9, typename T10,
3861    typename T11, typename T12, typename T13, typename T14, typename T15,
3862    typename T16, typename T17, typename T18, typename T19, typename T20,
3863    typename T21, typename T22, typename T23, typename T24, typename T25,
3864    typename T26, typename T27, typename T28, typename T29, typename T30,
3865    typename T31, typename T32, typename T33, typename T34, typename T35,
3866    typename T36, typename T37, typename T38, typename T39, typename T40,
3867    typename T41, typename T42, typename T43, typename T44, typename T45,
3868    typename T46, typename T47, typename T48, typename T49, typename T50>
3869struct Types50 {
3870  typedef T1 Head;
3871  typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
3872      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,
3873      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,
3874      T44, T45, T46, T47, T48, T49, T50> Tail;
3875};
3876
3877
3878}  // namespace internal
3879
3880// We don't want to require the users to write TypesN<...> directly,
3881// as that would require them to count the length.  Types<...> is much
3882// easier to write, but generates horrible messages when there is a
3883// compiler error, as gcc insists on printing out each template
3884// argument, even if it has the default value (this means Types<int>
3885// will appear as Types<int, None, None, ..., None> in the compiler
3886// errors).
3887//
3888// Our solution is to combine the best part of the two approaches: a
3889// user would write Types<T1, ..., TN>, and Google Test will translate
3890// that to TypesN<T1, ..., TN> internally to make error messages
3891// readable.  The translation is done by the 'type' member of the
3892// Types template.
3893template <typename T1 = internal::None, typename T2 = internal::None,
3894    typename T3 = internal::None, typename T4 = internal::None,
3895    typename T5 = internal::None, typename T6 = internal::None,
3896    typename T7 = internal::None, typename T8 = internal::None,
3897    typename T9 = internal::None, typename T10 = internal::None,
3898    typename T11 = internal::None, typename T12 = internal::None,
3899    typename T13 = internal::None, typename T14 = internal::None,
3900    typename T15 = internal::None, typename T16 = internal::None,
3901    typename T17 = internal::None, typename T18 = internal::None,
3902    typename T19 = internal::None, typename T20 = internal::None,
3903    typename T21 = internal::None, typename T22 = internal::None,
3904    typename T23 = internal::None, typename T24 = internal::None,
3905    typename T25 = internal::None, typename T26 = internal::None,
3906    typename T27 = internal::None, typename T28 = internal::None,
3907    typename T29 = internal::None, typename T30 = internal::None,
3908    typename T31 = internal::None, typename T32 = internal::None,
3909    typename T33 = internal::None, typename T34 = internal::None,
3910    typename T35 = internal::None, typename T36 = internal::None,
3911    typename T37 = internal::None, typename T38 = internal::None,
3912    typename T39 = internal::None, typename T40 = internal::None,
3913    typename T41 = internal::None, typename T42 = internal::None,
3914    typename T43 = internal::None, typename T44 = internal::None,
3915    typename T45 = internal::None, typename T46 = internal::None,
3916    typename T47 = internal::None, typename T48 = internal::None,
3917    typename T49 = internal::None, typename T50 = internal::None>
3918struct Types {
3919  typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
3920      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,
3921      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,
3922      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;
3923};
3924
3925template <>
3926struct Types<internal::None, internal::None, internal::None, internal::None,
3927    internal::None, internal::None, internal::None, internal::None,
3928    internal::None, internal::None, internal::None, internal::None,
3929    internal::None, internal::None, internal::None, internal::None,
3930    internal::None, internal::None, internal::None, internal::None,
3931    internal::None, internal::None, internal::None, internal::None,
3932    internal::None, internal::None, internal::None, internal::None,
3933    internal::None, internal::None, internal::None, internal::None,
3934    internal::None, internal::None, internal::None, internal::None,
3935    internal::None, internal::None, internal::None, internal::None,
3936    internal::None, internal::None, internal::None, internal::None,
3937    internal::None, internal::None, internal::None, internal::None,
3938    internal::None, internal::None> {
3939  typedef internal::Types0 type;
3940};
3941template <typename T1>
3942struct Types<T1, internal::None, internal::None, internal::None,
3943    internal::None, internal::None, internal::None, internal::None,
3944    internal::None, internal::None, internal::None, internal::None,
3945    internal::None, internal::None, internal::None, internal::None,
3946    internal::None, internal::None, internal::None, internal::None,
3947    internal::None, internal::None, internal::None, internal::None,
3948    internal::None, internal::None, internal::None, internal::None,
3949    internal::None, internal::None, internal::None, internal::None,
3950    internal::None, internal::None, internal::None, internal::None,
3951    internal::None, internal::None, internal::None, internal::None,
3952    internal::None, internal::None, internal::None, internal::None,
3953    internal::None, internal::None, internal::None, internal::None,
3954    internal::None, internal::None> {
3955  typedef internal::Types1<T1> type;
3956};
3957template <typename T1, typename T2>
3958struct Types<T1, T2, internal::None, internal::None, internal::None,
3959    internal::None, internal::None, internal::None, internal::None,
3960    internal::None, internal::None, internal::None, internal::None,
3961    internal::None, internal::None, internal::None, internal::None,
3962    internal::None, internal::None, internal::None, internal::None,
3963    internal::None, internal::None, internal::None, internal::None,
3964    internal::None, internal::None, internal::None, internal::None,
3965    internal::None, internal::None, internal::None, internal::None,
3966    internal::None, internal::None, internal::None, internal::None,
3967    internal::None, internal::None, internal::None, internal::None,
3968    internal::None, internal::None, internal::None, internal::None,
3969    internal::None, internal::None, internal::None, internal::None,
3970    internal::None> {
3971  typedef internal::Types2<T1, T2> type;
3972};
3973template <typename T1, typename T2, typename T3>
3974struct Types<T1, T2, T3, internal::None, internal::None, internal::None,
3975    internal::None, internal::None, internal::None, internal::None,
3976    internal::None, internal::None, internal::None, internal::None,
3977    internal::None, internal::None, internal::None, internal::None,
3978    internal::None, internal::None, internal::None, internal::None,
3979    internal::None, internal::None, internal::None, internal::None,
3980    internal::None, internal::None, internal::None, internal::None,
3981    internal::None, internal::None, internal::None, internal::None,
3982    internal::None, internal::None, internal::None, internal::None,
3983    internal::None, internal::None, internal::None, internal::None,
3984    internal::None, internal::None, internal::None, internal::None,
3985    internal::None, internal::None, internal::None, internal::None> {
3986  typedef internal::Types3<T1, T2, T3> type;
3987};
3988template <typename T1, typename T2, typename T3, typename T4>
3989struct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,
3990    internal::None, internal::None, internal::None, internal::None,
3991    internal::None, internal::None, internal::None, internal::None,
3992    internal::None, internal::None, internal::None, internal::None,
3993    internal::None, internal::None, internal::None, internal::None,
3994    internal::None, internal::None, internal::None, internal::None,
3995    internal::None, internal::None, internal::None, internal::None,
3996    internal::None, internal::None, internal::None, internal::None,
3997    internal::None, internal::None, internal::None, internal::None,
3998    internal::None, internal::None, internal::None, internal::None,
3999    internal::None, internal::None, internal::None, internal::None,
4000    internal::None, internal::None, internal::None> {
4001  typedef internal::Types4<T1, T2, T3, T4> type;
4002};
4003template <typename T1, typename T2, typename T3, typename T4, typename T5>
4004struct Types<T1, T2, T3, T4, T5, internal::None, internal::None,
4005    internal::None, internal::None, internal::None, internal::None,
4006    internal::None, internal::None, internal::None, internal::None,
4007    internal::None, internal::None, internal::None, internal::None,
4008    internal::None, internal::None, internal::None, internal::None,
4009    internal::None, internal::None, internal::None, internal::None,
4010    internal::None, internal::None, internal::None, internal::None,
4011    internal::None, internal::None, internal::None, internal::None,
4012    internal::None, internal::None, internal::None, internal::None,
4013    internal::None, internal::None, internal::None, internal::None,
4014    internal::None, internal::None, internal::None, internal::None,
4015    internal::None, internal::None, internal::None> {
4016  typedef internal::Types5<T1, T2, T3, T4, T5> type;
4017};
4018template <typename T1, typename T2, typename T3, typename T4, typename T5,
4019    typename T6>
4020struct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,
4021    internal::None, internal::None, internal::None, internal::None,
4022    internal::None, internal::None, internal::None, internal::None,
4023    internal::None, internal::None, internal::None, internal::None,
4024    internal::None, internal::None, internal::None, internal::None,
4025    internal::None, internal::None, internal::None, internal::None,
4026    internal::None, internal::None, internal::None, internal::None,
4027    internal::None, internal::None, internal::None, internal::None,
4028    internal::None, internal::None, internal::None, internal::None,
4029    internal::None, internal::None, internal::None, internal::None,
4030    internal::None, internal::None, internal::None, internal::None,
4031    internal::None, internal::None> {
4032  typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;
4033};
4034template <typename T1, typename T2, typename T3, typename T4, typename T5,
4035    typename T6, typename T7>
4036struct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,
4037    internal::None, internal::None, internal::None, internal::None,
4038    internal::None, internal::None, internal::None, internal::None,
4039    internal::None, internal::None, internal::None, internal::None,
4040    internal::None, internal::None, internal::None, internal::None,
4041    internal::None, internal::None, internal::None, internal::None,
4042    internal::None, internal::None, internal::None, internal::None,
4043    internal::None, internal::None, internal::None, internal::None,
4044    internal::None, internal::None, internal::None, internal::None,
4045    internal::None, internal::None, internal::None, internal::None,
4046    internal::None, internal::None, internal::None, internal::None,
4047    internal::None> {
4048  typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;
4049};
4050template <typename T1, typename T2, typename T3, typename T4, typename T5,
4051    typename T6, typename T7, typename T8>
4052struct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,
4053    internal::None, internal::None, internal::None, internal::None,
4054    internal::None, internal::None, internal::None, internal::None,
4055    internal::None, internal::None, internal::None, internal::None,
4056    internal::None, internal::None, internal::None, internal::None,
4057    internal::None, internal::None, internal::None, internal::None,
4058    internal::None, internal::None, internal::None, internal::None,
4059    internal::None, internal::None, internal::None, internal::None,
4060    internal::None, internal::None, internal::None, internal::None,
4061    internal::None, internal::None, internal::None, internal::None,
4062    internal::None, internal::None, internal::None, internal::None> {
4063  typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;
4064};
4065template <typename T1, typename T2, typename T3, typename T4, typename T5,
4066    typename T6, typename T7, typename T8, typename T9>
4067struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,
4068    internal::None, internal::None, internal::None, internal::None,
4069    internal::None, internal::None, internal::None, internal::None,
4070    internal::None, internal::None, internal::None, internal::None,
4071    internal::None, internal::None, internal::None, internal::None,
4072    internal::None, internal::None, internal::None, internal::None,
4073    internal::None, internal::None, internal::None, internal::None,
4074    internal::None, internal::None, internal::None, internal::None,
4075    internal::None, internal::None, internal::None, internal::None,
4076    internal::None, internal::None, internal::None, internal::None,
4077    internal::None, internal::None, internal::None, internal::None> {
4078  typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
4079};
4080template <typename T1, typename T2, typename T3, typename T4, typename T5,
4081    typename T6, typename T7, typename T8, typename T9, typename T10>
4082struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,
4083    internal::None, internal::None, internal::None, internal::None,
4084    internal::None, internal::None, internal::None, internal::None,
4085    internal::None, internal::None, internal::None, internal::None,
4086    internal::None, internal::None, internal::None, internal::None,
4087    internal::None, internal::None, internal::None, internal::None,
4088    internal::None, internal::None, internal::None, internal::None,
4089    internal::None, internal::None, internal::None, internal::None,
4090    internal::None, internal::None, internal::None, internal::None,
4091    internal::None, internal::None, internal::None, internal::None,
4092    internal::None, internal::None, internal::None> {
4093  typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;
4094};
4095template <typename T1, typename T2, typename T3, typename T4, typename T5,
4096    typename T6, typename T7, typename T8, typename T9, typename T10,
4097    typename T11>
4098struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,
4099    internal::None, internal::None, internal::None, internal::None,
4100    internal::None, internal::None, internal::None, internal::None,
4101    internal::None, internal::None, internal::None, internal::None,
4102    internal::None, internal::None, internal::None, internal::None,
4103    internal::None, internal::None, internal::None, internal::None,
4104    internal::None, internal::None, internal::None, internal::None,
4105    internal::None, internal::None, internal::None, internal::None,
4106    internal::None, internal::None, internal::None, internal::None,
4107    internal::None, internal::None, internal::None, internal::None,
4108    internal::None, internal::None> {
4109  typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;
4110};
4111template <typename T1, typename T2, typename T3, typename T4, typename T5,
4112    typename T6, typename T7, typename T8, typename T9, typename T10,
4113    typename T11, typename T12>
4114struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,
4115    internal::None, internal::None, internal::None, internal::None,
4116    internal::None, internal::None, internal::None, internal::None,
4117    internal::None, internal::None, internal::None, internal::None,
4118    internal::None, internal::None, internal::None, internal::None,
4119    internal::None, internal::None, internal::None, internal::None,
4120    internal::None, internal::None, internal::None, internal::None,
4121    internal::None, internal::None, internal::None, internal::None,
4122    internal::None, internal::None, internal::None, internal::None,
4123    internal::None, internal::None, internal::None, internal::None,
4124    internal::None> {
4125  typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
4126      T12> type;
4127};
4128template <typename T1, typename T2, typename T3, typename T4, typename T5,
4129    typename T6, typename T7, typename T8, typename T9, typename T10,
4130    typename T11, typename T12, typename T13>
4131struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,
4132    internal::None, internal::None, internal::None, internal::None,
4133    internal::None, internal::None, internal::None, internal::None,
4134    internal::None, internal::None, internal::None, internal::None,
4135    internal::None, internal::None, internal::None, internal::None,
4136    internal::None, internal::None, internal::None, internal::None,
4137    internal::None, internal::None, internal::None, internal::None,
4138    internal::None, internal::None, internal::None, internal::None,
4139    internal::None, internal::None, internal::None, internal::None,
4140    internal::None, internal::None, internal::None, internal::None,
4141    internal::None> {
4142  typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4143      T13> type;
4144};
4145template <typename T1, typename T2, typename T3, typename T4, typename T5,
4146    typename T6, typename T7, typename T8, typename T9, typename T10,
4147    typename T11, typename T12, typename T13, typename T14>
4148struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,
4149    internal::None, internal::None, internal::None, internal::None,
4150    internal::None, internal::None, internal::None, internal::None,
4151    internal::None, internal::None, internal::None, internal::None,
4152    internal::None, internal::None, internal::None, internal::None,
4153    internal::None, internal::None, internal::None, internal::None,
4154    internal::None, internal::None, internal::None, internal::None,
4155    internal::None, internal::None, internal::None, internal::None,
4156    internal::None, internal::None, internal::None, internal::None,
4157    internal::None, internal::None, internal::None, internal::None> {
4158  typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4159      T13, T14> type;
4160};
4161template <typename T1, typename T2, typename T3, typename T4, typename T5,
4162    typename T6, typename T7, typename T8, typename T9, typename T10,
4163    typename T11, typename T12, typename T13, typename T14, typename T15>
4164struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4165    internal::None, internal::None, internal::None, internal::None,
4166    internal::None, internal::None, internal::None, internal::None,
4167    internal::None, internal::None, internal::None, internal::None,
4168    internal::None, internal::None, internal::None, internal::None,
4169    internal::None, internal::None, internal::None, internal::None,
4170    internal::None, internal::None, internal::None, internal::None,
4171    internal::None, internal::None, internal::None, internal::None,
4172    internal::None, internal::None, internal::None, internal::None,
4173    internal::None, internal::None, internal::None> {
4174  typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4175      T13, T14, T15> type;
4176};
4177template <typename T1, typename T2, typename T3, typename T4, typename T5,
4178    typename T6, typename T7, typename T8, typename T9, typename T10,
4179    typename T11, typename T12, typename T13, typename T14, typename T15,
4180    typename T16>
4181struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4182    T16, internal::None, internal::None, internal::None, internal::None,
4183    internal::None, internal::None, internal::None, internal::None,
4184    internal::None, internal::None, internal::None, internal::None,
4185    internal::None, internal::None, internal::None, internal::None,
4186    internal::None, internal::None, internal::None, internal::None,
4187    internal::None, internal::None, internal::None, internal::None,
4188    internal::None, internal::None, internal::None, internal::None,
4189    internal::None, internal::None, internal::None, internal::None,
4190    internal::None, internal::None> {
4191  typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4192      T13, T14, T15, T16> type;
4193};
4194template <typename T1, typename T2, typename T3, typename T4, typename T5,
4195    typename T6, typename T7, typename T8, typename T9, typename T10,
4196    typename T11, typename T12, typename T13, typename T14, typename T15,
4197    typename T16, typename T17>
4198struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4199    T16, T17, internal::None, internal::None, internal::None, internal::None,
4200    internal::None, internal::None, internal::None, internal::None,
4201    internal::None, internal::None, internal::None, internal::None,
4202    internal::None, internal::None, internal::None, internal::None,
4203    internal::None, internal::None, internal::None, internal::None,
4204    internal::None, internal::None, internal::None, internal::None,
4205    internal::None, internal::None, internal::None, internal::None,
4206    internal::None, internal::None, internal::None, internal::None,
4207    internal::None> {
4208  typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4209      T13, T14, T15, T16, T17> type;
4210};
4211template <typename T1, typename T2, typename T3, typename T4, typename T5,
4212    typename T6, typename T7, typename T8, typename T9, typename T10,
4213    typename T11, typename T12, typename T13, typename T14, typename T15,
4214    typename T16, typename T17, typename T18>
4215struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4216    T16, T17, T18, internal::None, internal::None, internal::None,
4217    internal::None, internal::None, internal::None, internal::None,
4218    internal::None, internal::None, internal::None, internal::None,
4219    internal::None, internal::None, internal::None, internal::None,
4220    internal::None, internal::None, internal::None, internal::None,
4221    internal::None, internal::None, internal::None, internal::None,
4222    internal::None, internal::None, internal::None, internal::None,
4223    internal::None, internal::None, internal::None, internal::None,
4224    internal::None> {
4225  typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4226      T13, T14, T15, T16, T17, T18> type;
4227};
4228template <typename T1, typename T2, typename T3, typename T4, typename T5,
4229    typename T6, typename T7, typename T8, typename T9, typename T10,
4230    typename T11, typename T12, typename T13, typename T14, typename T15,
4231    typename T16, typename T17, typename T18, typename T19>
4232struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4233    T16, T17, T18, T19, internal::None, internal::None, internal::None,
4234    internal::None, internal::None, internal::None, internal::None,
4235    internal::None, internal::None, internal::None, internal::None,
4236    internal::None, internal::None, internal::None, internal::None,
4237    internal::None, internal::None, internal::None, internal::None,
4238    internal::None, internal::None, internal::None, internal::None,
4239    internal::None, internal::None, internal::None, internal::None,
4240    internal::None, internal::None, internal::None, internal::None> {
4241  typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4242      T13, T14, T15, T16, T17, T18, T19> type;
4243};
4244template <typename T1, typename T2, typename T3, typename T4, typename T5,
4245    typename T6, typename T7, typename T8, typename T9, typename T10,
4246    typename T11, typename T12, typename T13, typename T14, typename T15,
4247    typename T16, typename T17, typename T18, typename T19, typename T20>
4248struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4249    T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,
4250    internal::None, internal::None, internal::None, internal::None,
4251    internal::None, internal::None, internal::None, internal::None,
4252    internal::None, internal::None, internal::None, internal::None,
4253    internal::None, internal::None, internal::None, internal::None,
4254    internal::None, internal::None, internal::None, internal::None,
4255    internal::None, internal::None, internal::None, internal::None,
4256    internal::None, internal::None, internal::None> {
4257  typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4258      T13, T14, T15, T16, T17, T18, T19, T20> type;
4259};
4260template <typename T1, typename T2, typename T3, typename T4, typename T5,
4261    typename T6, typename T7, typename T8, typename T9, typename T10,
4262    typename T11, typename T12, typename T13, typename T14, typename T15,
4263    typename T16, typename T17, typename T18, typename T19, typename T20,
4264    typename T21>
4265struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4266    T16, T17, T18, T19, T20, T21, internal::None, internal::None,
4267    internal::None, internal::None, internal::None, internal::None,
4268    internal::None, internal::None, internal::None, internal::None,
4269    internal::None, internal::None, internal::None, internal::None,
4270    internal::None, internal::None, internal::None, internal::None,
4271    internal::None, internal::None, internal::None, internal::None,
4272    internal::None, internal::None, internal::None, internal::None,
4273    internal::None, internal::None, internal::None> {
4274  typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4275      T13, T14, T15, T16, T17, T18, T19, T20, T21> type;
4276};
4277template <typename T1, typename T2, typename T3, typename T4, typename T5,
4278    typename T6, typename T7, typename T8, typename T9, typename T10,
4279    typename T11, typename T12, typename T13, typename T14, typename T15,
4280    typename T16, typename T17, typename T18, typename T19, typename T20,
4281    typename T21, typename T22>
4282struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4283    T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,
4284    internal::None, internal::None, internal::None, internal::None,
4285    internal::None, internal::None, internal::None, internal::None,
4286    internal::None, internal::None, internal::None, internal::None,
4287    internal::None, internal::None, internal::None, internal::None,
4288    internal::None, internal::None, internal::None, internal::None,
4289    internal::None, internal::None, internal::None, internal::None,
4290    internal::None, internal::None> {
4291  typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
4292      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;
4293};
4294template <typename T1, typename T2, typename T3, typename T4, typename T5,
4295    typename T6, typename T7, typename T8, typename T9, typename T10,
4296    typename T11, typename T12, typename T13, typename T14, typename T15,
4297    typename T16, typename T17, typename T18, typename T19, typename T20,
4298    typename T21, typename T22, typename T23>
4299struct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
4300    T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,
4301    internal::None, internal::None, internal::None, internal::None,
4302    internal::None, internal::None, internal::None, internal::None,
4303    internal::None, internal::None, internal::None, internal::None,
4304    internal::None, internal::None, internal::None, internal::None,
4305    internal::None, internal::None, internal::None, internal::None,
4306    internal::None, internal::None, internal::None, internal::None,
4307    internal::None> {