Skip to content

Commit

Permalink
Include <optional> if possible to check if we can use the feature (#309)
Browse files Browse the repository at this point in the history
Fixes #303
  • Loading branch information
ollien committed Oct 10, 2021
1 parent c641241 commit 4a02ad9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions include/cxxopts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1361,7 +1366,7 @@ namespace cxxopts
{
return m_count;
}

#if defined(CXXOPTS_NULL_DEREF_IGNORE)
#pragma GCC diagnostic pop
#endif
Expand Down

0 comments on commit 4a02ad9

Please sign in to comment.