From e17deb7ad4ac83207c9e34d397f3ee054b3d09dd Mon Sep 17 00:00:00 2001 From: Mathieu Garaud Date: Wed, 27 Feb 2019 15:47:41 +0100 Subject: 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. --- Source/Checks/cm_cxx14_check.cpp | 9 ++++++++- Source/Checks/cm_cxx17_check.cpp | 11 ++++++++++- 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 +#include #include 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 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 4e89184..9ea52c4 100644 --- a/Source/Checks/cm_cxx17_check.cpp +++ b/Source/Checks/cm_cxx17_check.cpp @@ -1,9 +1,18 @@ #include +#include #include #include 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 u(new int(0)); - return *u; + return *u + *ai + *(bi - 1) + (3 - static_cast(ci)); } -- cgit v0.12