Skip to content

Commit 84e8e9a

Browse files
committed
Prevent compiler error when using std::experimental::optional
1 parent c618242 commit 84e8e9a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/cpp/loggingevent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ bool LoggingEvent::getNDC(LogString& dest) const
206206
// Otherwise use the NDC that is associated with the thread.
207207
if (m_priv->dc)
208208
{
209-
result = m_priv->dc->ctx.has_value();
209+
result = bool(m_priv->dc->ctx);
210210
if (result)
211211
dest.append(NDC::getFullMessage(m_priv->dc->ctx.value()));
212212
}

src/main/include/log4cxx/helpers/optional.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class Optional : private std::pair<bool, T>
5353
this->second = value;
5454
return *this;
5555
}
56-
bool has_value() const { return this->first; }
57-
const T& value() const { return this->second; }
56+
constexpr explicit operator bool() const noexcept { return this->first; }
57+
constexpr bool has_value() const noexcept { return this->first; }
58+
constexpr const T& value() const noexcept { return this->second; }
5859
};
5960
} // namespace LOG4CXX_NS
6061
#endif

0 commit comments

Comments
 (0)