|
72 | 72 | // Test's own tr1 tuple implementation should be
|
73 | 73 | // used. Unused when the user sets
|
74 | 74 | // GTEST_HAS_TR1_TUPLE to 0.
|
| 75 | +// GTEST_LANG_CXX11 - Define it to 1/0 to indicate that Google Test |
| 76 | +// is building in C++11/C++98 mode. |
75 | 77 | // GTEST_LINKED_AS_SHARED_LIBRARY
|
76 | 78 | // - Define to 1 when compiling tests that use
|
77 | 79 | // Google Test as a shared library (known as
|
|
259 | 261 | # define GTEST_OS_QNX 1
|
260 | 262 | #endif // __CYGWIN__
|
261 | 263 |
|
| 264 | +#ifndef GTEST_LANG_CXX11 |
| 265 | +// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when |
| 266 | +// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a |
| 267 | +// value for __cplusplus, and recent versions of clang, gcc, and |
| 268 | +// probably other compilers set that too in C++11 mode. |
| 269 | +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L |
| 270 | +// Compiling in at least C++11 mode. |
| 271 | +# define GTEST_LANG_CXX11 1 |
| 272 | +# else |
| 273 | +# define GTEST_LANG_CXX11 0 |
| 274 | +# endif |
| 275 | +#endif |
| 276 | + |
262 | 277 | // Brings in definitions for functions used in the testing::internal::posix
|
263 | 278 | // namespace (read, write, close, chdir, isatty, stat). We do not currently
|
264 | 279 | // use them on Windows Mobile.
|
|
267 | 282 | // is not the case, we need to include headers that provide the functions
|
268 | 283 | // mentioned above.
|
269 | 284 | # include <unistd.h>
|
270 |
| -# if !GTEST_OS_NACL |
271 |
| -// TODO([email protected]): Remove this condition when Native Client SDK adds |
272 |
| -// strings.h (tracked in |
273 |
| -// http://code.google.com/p/nativeclient/issues/detail?id=1175). |
274 |
| -# include <strings.h> // Native Client doesn't provide strings.h. |
275 |
| -# endif |
| 285 | +# include <strings.h> |
276 | 286 | #elif !GTEST_OS_WINDOWS_MOBILE
|
277 | 287 | # include <direct.h>
|
278 | 288 | # include <io.h>
|
|
466 | 476 | // The user didn't tell us, so we need to figure it out.
|
467 | 477 |
|
468 | 478 | // We use our own TR1 tuple if we aren't sure the user has an
|
469 |
| -// implementation of it already. At this time, GCC 4.0.0+ and MSVC |
470 |
| -// 2010 are the only mainstream compilers that come with a TR1 tuple |
471 |
| -// implementation. NVIDIA's CUDA NVCC compiler pretends to be GCC by |
472 |
| -// defining __GNUC__ and friends, but cannot compile GCC's tuple |
473 |
| -// implementation. MSVC 2008 (9.0) provides TR1 tuple in a 323 MB |
474 |
| -// Feature Pack download, which we cannot assume the user has. |
475 |
| -// QNX's QCC compiler is a modified GCC but it doesn't support TR1 tuple. |
| 479 | +// implementation of it already. At this time, libstdc++ 4.0.0+ and |
| 480 | +// MSVC 2010 are the only mainstream standard libraries that come |
| 481 | +// with a TR1 tuple implementation. NVIDIA's CUDA NVCC compiler |
| 482 | +// pretends to be GCC by defining __GNUC__ and friends, but cannot |
| 483 | +// compile GCC's tuple implementation. MSVC 2008 (9.0) provides TR1 |
| 484 | +// tuple in a 323 MB Feature Pack download, which we cannot assume the |
| 485 | +// user has. QNX's QCC compiler is a modified GCC but it doesn't |
| 486 | +// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, |
| 487 | +// and it can be used with some compilers that define __GNUC__. |
476 | 488 | # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \
|
477 |
| - && !GTEST_OS_QNX) || _MSC_VER >= 1600 |
| 489 | + && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 |
| 490 | +# define GTEST_ENV_HAS_TR1_TUPLE_ 1 |
| 491 | +# endif |
| 492 | + |
| 493 | +// C++11 specifies that <tuple> provides std::tuple. Users can't use |
| 494 | +// gtest in C++11 mode until their standard library is at least that |
| 495 | +// compliant. |
| 496 | +# if GTEST_LANG_CXX11 |
| 497 | +# define GTEST_ENV_HAS_STD_TUPLE_ 1 |
| 498 | +# endif |
| 499 | + |
| 500 | +# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_ |
478 | 501 | # define GTEST_USE_OWN_TR1_TUPLE 0
|
479 | 502 | # else
|
480 | 503 | # define GTEST_USE_OWN_TR1_TUPLE 1
|
|
489 | 512 |
|
490 | 513 | # if GTEST_USE_OWN_TR1_TUPLE
|
491 | 514 | # include "gtest/internal/gtest-tuple.h"
|
| 515 | +# elif GTEST_ENV_HAS_STD_TUPLE_ |
| 516 | +# include <tuple> |
| 517 | +// C++11 puts its tuple into the ::std namespace rather than |
| 518 | +// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there. |
| 519 | +// This causes undefined behavior, but supported compilers react in |
| 520 | +// the way we intend. |
| 521 | +namespace std { |
| 522 | +namespace tr1 { |
| 523 | +using ::std::get; |
| 524 | +using ::std::make_tuple; |
| 525 | +using ::std::tuple; |
| 526 | +using ::std::tuple_element; |
| 527 | +using ::std::tuple_size; |
| 528 | +} |
| 529 | +} |
| 530 | + |
492 | 531 | # elif GTEST_OS_SYMBIAN
|
493 | 532 |
|
494 | 533 | // On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to
|
|
0 commit comments