Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jarro2783/cxxopts.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Krichevsky <njk828@gmail.com>2021-10-10 05:01:47 +0300
committerGitHub <noreply@github.com>2021-10-10 05:01:47 +0300
commit4a02ad94f42841fc718bbcf128e0b674b336a074 (patch)
tree7c7b73e16bf2ca3bf480670a437c44e5e445ca91
parentc641241a87cba7efdcb8f2145649763940784982 (diff)
Include <optional> if possible to check if we can use the feature (#309)
Fixes #303
-rw-r--r--include/cxxopts.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp
index 58b5d45..870755a 100644
--- a/include/cxxopts.hpp
+++ b/include/cxxopts.hpp
@@ -51,9 +51,14 @@ THE SOFTWARE.
# include <regex>
#endif // CXXOPTS_NO_REGEX
-#ifdef __cpp_lib_optional
-#include <optional>
-#define CXXOPTS_HAS_OPTIONAL
+// Nonstandard before C++17, which is coincidentally what we also need for <optional>
+#ifdef __has_include
+# if __has_include(<optional>)
+# include <optional>
+# ifdef __cpp_lib_optional
+# define CXXOPTS_HAS_OPTIONAL
+# endif
+# endif
#endif
#if __cplusplus >= 201603L
@@ -1361,7 +1366,7 @@ namespace cxxopts
{
return m_count;
}
-
+
#if defined(CXXOPTS_NULL_DEREF_IGNORE)
#pragma GCC diagnostic pop
#endif