18 #ifndef LOG4CXX_OPTIONAL_HDR_
19 #define LOG4CXX_OPTIONAL_HDR_
21 #ifdef __has_include // Check if __has_include is present
22 # if __has_include(<optional>) // Check for a standard version
24 # if defined(__cpp_lib_optional) // C++ >= 17
25 namespace LOG4CXX_NS {
template<
class T >
using Optional = std::optional<T>; }
26 #define LOG4CXX_HAS_STD_OPTIONAL 1
28 # elif __has_include(<experimental/optional>) // Check for an experimental version
29 # include <experimental/optional>
30 namespace LOG4CXX_NS {
template<
class T >
using Optional = std::experimental::optional<T>; }
31 #define LOG4CXX_HAS_STD_OPTIONAL 1
32 # elif __has_include(<boost/optional.hpp>) // Try with an external library
33 # include <boost/optional.hpp>
34 namespace LOG4CXX_NS {
template<
class T >
using Optional = boost::optional<T>; }
35 #define LOG4CXX_HAS_STD_OPTIONAL 1
36 # else // Not found at all
37 #define LOG4CXX_HAS_STD_OPTIONAL 0
41 #if !LOG4CXX_HAS_STD_OPTIONAL // Implement a minimal Optional?
47 using BaseType = std::pair<bool, T>;
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; }
63 #endif // LOG4CXX_OPTIONAL_HDR_