diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 7224807..1b59fde 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -1543,6 +1543,9 @@ CXXOPTS_DIAGNOSTIC_POP std::optional as_optional() const { + if (m_value == nullptr) { + return std::nullopt; + } return as(); } #endif