summaryrefslogtreecommitdiffstats
path: root/Source/Checks/cm_cxx14_check.cpp
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/cm_cxx14_check.cpp
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/cm_cxx14_check.cpp')
-rw-r--r--Source/Checks/cm_cxx14_check.cpp9
1 files changed, 8 insertions, 1 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);
}