--- Source/Checks/cm_cxx14_check.cpp.orig +++ Source/Checks/cm_cxx14_check.cpp @@ -1,9 +1,18 @@ +// actually use c++14 feature to force the compiler to do something, +// since it might otherwise try to optimize all of this out even if it +// doesn't understand it. +#include <iostream> + #include <cstdio> #include <iterator> #include <memory> int main() { + std::unique_ptr < int > foo = std::make_unique < int > (4); + std::cout << "std::make_unique < int >(4) is '" + << *foo << "'" << std::endl; + int a[] = { 0, 1, 2 }; auto ai = std::cbegin(a); --- Source/Checks/cm_cxx17_check.cpp.orig +++ Source/Checks/cm_cxx17_check.cpp @@ -1,3 +1,9 @@ +// actually use c++17 feature to force the compiler to do something, +// since it might otherwise try to optimize all of this out even if it +// doesn't understand it. +#include <iostream> +#include <string> + #include <cstdio> #include <iterator> #include <memory> @@ -15,6 +21,15 @@ return item.get(); } +std::optional < std::string > +create +(bool b) { + if (b) { + return "foo!"; + } + return {}; +} + int main() { int a[] = { 0, 1, 2 }; @@ -38,6 +53,13 @@ IDispatchPtr disp(ptr); #endif + std::cout << "create(false) returned " + << create(false).value_or("empty") + << std::endl; + std::cout << "create(true) returned " + << create(true).value_or("empty") + << std::endl; + std::optional<int> oi = 0; return *u + *ai + *(bi - 1) + (3 - static_cast<int>(ci)) + oi.value();