summaryrefslogtreecommitdiffstats
path: root/Source/Checks
diff options
context:
space:
mode:
authorMathieu Garaud <mathieu.garaud@gmail.com>2019-02-27 14:47:41 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-27 16:27:17 (GMT)
commita605bf438e303b3fa7fa3c3b5dfbcb5164c1e7d7 (patch)
treea2e7a18a4ba19ceb265bc24692093b44e3674dd7 /Source/Checks
parentb3191a0f5740d5efa5d6286d3f7c2b9356fa87c0 (diff)
downloadCMake-a605bf438e303b3fa7fa3c3b5dfbcb5164c1e7d7.zip
CMake-a605bf438e303b3fa7fa3c3b5dfbcb5164c1e7d7.tar.gz
CMake-a605bf438e303b3fa7fa3c3b5dfbcb5164c1e7d7.tar.bz2
Extend C++17/C++14 feature checks to cover more standard library APIs
Make sure `std::cbegin`, `std::cend`, and `std::size` work in C++17 or C++14 mode before choosing the corresponding standard level for compiling CMake itself. This helps in cases that the compiler is using a standard library too old to support the full standard level chosen.
Diffstat (limited to 'Source/Checks')
-rw-r--r--Source/Checks/cm_cxx14_check.cpp9
-rw-r--r--Source/Checks/cm_cxx17_check.cpp11
2 files changed, 18 insertions, 2 deletions
diff --git a/Source/Checks/cm_cxx14_check.cpp b/Source/Checks/cm_cxx14_check.cpp
index 9369ba2..fff36c9 100644
--- a/Source/Checks/cm_cxx14_check.cpp
+++ b/Source/Checks/cm_cxx14_check.cpp
@@ -1,8 +1,15 @@
#include <cstdio>
+#include <iterator>
#include <memory>
int main()
{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
std::unique_ptr<int> u(new int(0));
- return *u;
+ return *u + *ai + *(bi - 1);
}
diff --git a/Source/Checks/cm_cxx17_check.cpp b/Source/Checks/cm_cxx17_check.cpp
index 2de10d6..593d9b2 100644
--- a/Source/Checks/cm_cxx17_check.cpp
+++ b/Source/Checks/cm_cxx17_check.cpp
@@ -1,4 +1,5 @@
#include <cstdio>
+#include <iterator>
#include <memory>
#include <unordered_map>
@@ -8,6 +9,14 @@
int main()
{
+ int a[] = { 0, 1, 2 };
+ auto ai = std::cbegin(a);
+
+ int b[] = { 2, 1, 0 };
+ auto bi = std::cend(b);
+
+ auto ci = std::size(a);
+
std::unique_ptr<int> u(new int(0));
#ifdef _MSC_VER
@@ -18,5 +27,5 @@ int main()
IDispatchPtr disp(ptr);
#endif
- return *u;
+ return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci));
}