Distinguish between C++11 language and library support for std::function, std::begin, std::end, and std::move in gtest and gmock.

This commit is contained in:
kosak 2014-11-17 00:27:28 +00:00
parent 6884259b7d
commit 6aa0422e85
2 changed files with 29 additions and 7 deletions

View File

@ -377,12 +377,34 @@
# endif
#endif
// C++11 specifies that <initializer_list> provides std::initializer_list. Use
// that if gtest is used in C++11 mode and libstdc++ isn't very old (binaries
// targeting OS X 10.6 can build with clang but need to use gcc4.2's
// libstdc++).
#if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)
// Distinct from C++11 language support, some environments don't provide
// proper C++11 library support. Notably, it's possible to build in
// C++11 mode when targeting Mac OS X 10.6, which has an old libstdc++
// with no C++11 support.
//
// libstdc++ has sufficient C++11 support as of GCC 4.6.0, __GLIBCXX__
// 20110325, but maintenance releases in the 4.4 and 4.5 series followed
// this date, so check for those versions by their date stamps.
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html#abi.versioning
#if GTEST_LANG_CXX11 && \
(!defined(__GLIBCXX__) || ( \
__GLIBCXX__ >= 20110325ul && /* GCC >= 4.6.0 */ \
/* Blacklist of patch releases of older branches: */ \
__GLIBCXX__ != 20110416ul && /* GCC 4.4.6 */ \
__GLIBCXX__ != 20120313ul && /* GCC 4.4.7 */ \
__GLIBCXX__ != 20110428ul && /* GCC 4.5.3 */ \
__GLIBCXX__ != 20120702ul)) /* GCC 4.5.4 */
# define GTEST_STDLIB_CXX11 1
#endif
// Only use C++11 library features if the library provides them.
#if GTEST_STDLIB_CXX11
# define GTEST_HAS_STD_BEGIN_AND_END_ 1
# define GTEST_HAS_STD_FORWARD_LIST_ 1
# define GTEST_HAS_STD_FUNCTION_ 1
# define GTEST_HAS_STD_INITIALIZER_LIST_ 1
# define GTEST_HAS_STD_MOVE_ 1
# define GTEST_HAS_STD_UNIQUE_PTR_ 1
#endif
// C++11 specifies that <tuple> provides std::tuple.
@ -883,7 +905,7 @@ using ::std::tuple_size;
# define GTEST_MUST_USE_RESULT_
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
#if GTEST_LANG_CXX11
#if GTEST_HAS_STD_MOVE_
# define GTEST_MOVE_(x) ::std::move(x) // NOLINT
#else
# define GTEST_MOVE_(x) x

View File

@ -1037,7 +1037,7 @@ TEST(PrintTr1TupleTest, NestedTuple) {
#endif // GTEST_HAS_TR1_TUPLE
#if GTEST_LANG_CXX11
#if GTEST_HAS_STD_TUPLE_
// Tests printing ::std::tuples.
// Tuples of various arities.