mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
Extend C++17 feature checks to require std::optional
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -27,5 +28,7 @@ int main()
|
||||
IDispatchPtr disp(ptr);
|
||||
#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
|
||||
|
||||
#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
|
||||
{
|
||||
public:
|
||||
@@ -1156,7 +1170,7 @@ private:
|
||||
int main()
|
||||
{
|
||||
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;
|
||||
}
|
||||
' > "${TMPFILE}.cxx"
|
||||
|
Reference in New Issue
Block a user