mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 07:11:52 +08:00
Extend C++17 feature checks to require std::optional
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
@@ -27,5 +28,7 @@ int main()
|
|||||||
IDispatchPtr disp(ptr);
|
IDispatchPtr disp(ptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci));
|
std::optional<int> oi = 0;
|
||||||
|
|
||||||
|
return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci)) + oi.value();
|
||||||
}
|
}
|
||||||
|
16
bootstrap
16
bootstrap
@@ -1146,6 +1146,20 @@ int check_cxx14()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __cplusplus >= 201703L
|
||||||
|
#include <optional>
|
||||||
|
int check_cxx17()
|
||||||
|
{
|
||||||
|
std::optional<int> oi = 0;
|
||||||
|
return oi.value();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int check_cxx17()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
class Class
|
class Class
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -1156,7 +1170,7 @@ private:
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
auto const c = std::unique_ptr<Class>(new Class);
|
auto const c = std::unique_ptr<Class>(new Class);
|
||||||
std::cout << c->Get() << check_cxx14() << std::endl;
|
std::cout << c->Get() << check_cxx14() << check_cxx17() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
' > "${TMPFILE}.cxx"
|
' > "${TMPFILE}.cxx"
|
||||||
|
Reference in New Issue
Block a user