summaryrefslogtreecommitdiff
path: root/doctest
diff options
context:
space:
mode:
authoronqtam <vik.kirilov@gmail.com>2017-03-23 17:13:30 +0200
committeronqtam <vik.kirilov@gmail.com>2017-05-16 00:22:16 +0300
commit7ccebe0f9811316dbf5c06577a07e21a2eb242a1 (patch)
tree88977c48c32e61b7c597d583796ddc0f9d668ed9 /doctest
parentcad5cf40ec3482b7dfbb5dee59cc68b6717e6388 (diff)
- added detection of rvalue reference support of compilers
Diffstat (limited to 'doctest')
-rw-r--r--doctest/doctest.h44
-rw-r--r--doctest/parts/doctest_fwd.h44
2 files changed, 76 insertions, 12 deletions
diff --git a/doctest/doctest.h b/doctest/doctest.h
index 29619af..8a4dbe3 100644
--- a/doctest/doctest.h
+++ b/doctest/doctest.h
@@ -98,6 +98,9 @@
// =================================================================================================
#if __cplusplus >= 201103L
+#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
#ifndef DOCTEST_CONFIG_WITH_NULLPTR
#define DOCTEST_CONFIG_WITH_NULLPTR
#endif // DOCTEST_CONFIG_WITH_NULLPTR
@@ -112,13 +115,44 @@
#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
#endif // __cplusplus >= 201103L
+// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
+// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
+// MSVC version table:
+// MSVC++ xxxx _MSC_VER == xxxx (Visual Studio 2017)
+// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
+// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
+// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
+// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
+// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
+// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif // __has_feature
+
+// rvalue references
+
+#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#if defined(_MSC_VER) && (_MSC_VER >= 1600)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // _MSC_VER
+#if defined(__clang__) && __has_feature(cxx_rvalue_references)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // __clang__
+#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // __GNUC__
+#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+
+#if defined(DOCTEST_CONFIG_NO_RVALUE_REFERENCES) && defined(DOCTEST_CONFIG_WITH_RVALUE_REFERENCES)
+#undef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // DOCTEST_CONFIG_NO_RVALUE_REFERENCES
+
// nullptr
#ifndef DOCTEST_CONFIG_WITH_NULLPTR
-#ifdef __clang__
-#if __has_feature(cxx_nullptr)
+#if defined(__clang__) && __has_feature(cxx_nullptr)
#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // __has_feature(cxx_nullptr)
#endif // __clang__
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define DOCTEST_CONFIG_WITH_NULLPTR
@@ -166,10 +200,8 @@
// static_assert
#ifndef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#ifdef __clang__
-#if __has_feature(cxx_static_assert)
+#if defined(__clang__) && __has_feature(cxx_static_assert)
#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // __has_feature(cxx_static_assert)
#endif // __clang__
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
diff --git a/doctest/parts/doctest_fwd.h b/doctest/parts/doctest_fwd.h
index 2e2dfd4..b392e55 100644
--- a/doctest/parts/doctest_fwd.h
+++ b/doctest/parts/doctest_fwd.h
@@ -95,6 +95,9 @@
// =================================================================================================
#if __cplusplus >= 201103L
+#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
#ifndef DOCTEST_CONFIG_WITH_NULLPTR
#define DOCTEST_CONFIG_WITH_NULLPTR
#endif // DOCTEST_CONFIG_WITH_NULLPTR
@@ -109,13 +112,44 @@
#endif // DOCTEST_CONFIG_WITH_VARIADIC_MACROS
#endif // __cplusplus >= 201103L
+// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
+// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
+// MSVC version table:
+// MSVC++ xxxx _MSC_VER == xxxx (Visual Studio 2017)
+// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
+// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
+// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
+// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
+// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
+// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
+
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif // __has_feature
+
+// rvalue references
+
+#ifndef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#if defined(_MSC_VER) && (_MSC_VER >= 1600)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // _MSC_VER
+#if defined(__clang__) && __has_feature(cxx_rvalue_references)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // __clang__
+#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
+#define DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // __GNUC__
+#endif // DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+
+#if defined(DOCTEST_CONFIG_NO_RVALUE_REFERENCES) && defined(DOCTEST_CONFIG_WITH_RVALUE_REFERENCES)
+#undef DOCTEST_CONFIG_WITH_RVALUE_REFERENCES
+#endif // DOCTEST_CONFIG_NO_RVALUE_REFERENCES
+
// nullptr
#ifndef DOCTEST_CONFIG_WITH_NULLPTR
-#ifdef __clang__
-#if __has_feature(cxx_nullptr)
+#if defined(__clang__) && __has_feature(cxx_nullptr)
#define DOCTEST_CONFIG_WITH_NULLPTR
-#endif // __has_feature(cxx_nullptr)
#endif // __clang__
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define DOCTEST_CONFIG_WITH_NULLPTR
@@ -163,10 +197,8 @@
// static_assert
#ifndef DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#ifdef __clang__
-#if __has_feature(cxx_static_assert)
+#if defined(__clang__) && __has_feature(cxx_static_assert)
#define DOCTEST_CONFIG_WITH_STATIC_ASSERT
-#endif // __has_feature(cxx_static_assert)
#endif // __clang__
#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define DOCTEST_CONFIG_WITH_STATIC_ASSERT