Skip to content

Commit

Permalink
Prevent compiler error when using std::experimental::optional (#419)
Browse files Browse the repository at this point in the history
  • Loading branch information
swebb2066 authored Oct 23, 2024
1 parent c618242 commit 0ff3c8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/cpp/loggingevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/include/log4cxx/helpers/optional.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ class Optional : private std::pair<bool, T>
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
Expand Down

0 comments on commit 0ff3c8a

Please sign in to comment.