This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch support_std_experimental_optional in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 84e8e9aa56b5cb4683cf36c08f14918dce9f8df6 Author: Stephen Webb <[email protected]> AuthorDate: Wed Oct 23 14:46:32 2024 +1100 Prevent compiler error when using std::experimental::optional --- src/main/cpp/loggingevent.cpp | 2 +- src/main/include/log4cxx/helpers/optional.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp index d3431698..0fc0dacf 100644 --- a/src/main/cpp/loggingevent.cpp +++ b/src/main/cpp/loggingevent.cpp @@ -206,7 +206,7 @@ bool LoggingEvent::getNDC(LogString& dest) const // Otherwise use the NDC that is associated with the thread. if (m_priv->dc) { - result = m_priv->dc->ctx.has_value(); + result = bool(m_priv->dc->ctx); if (result) dest.append(NDC::getFullMessage(m_priv->dc->ctx.value())); } diff --git a/src/main/include/log4cxx/helpers/optional.h b/src/main/include/log4cxx/helpers/optional.h index b4a7be72..f9c20075 100644 --- a/src/main/include/log4cxx/helpers/optional.h +++ b/src/main/include/log4cxx/helpers/optional.h @@ -53,8 +53,9 @@ public: this->second = value; return *this; } - bool has_value() const { return this->first; } - const T& value() const { return this->second; } + constexpr explicit operator bool() const noexcept { return this->first; } + constexpr bool has_value() const noexcept { return this->first; } + constexpr const T& value() const noexcept { return this->second; } }; } // namespace LOG4CXX_NS #endif
