8#ifndef __ABG_CXX_COMPAT_H
9#define __ABG_CXX_COMPAT_H
13#if __cplusplus >= 201703L
25#if __cplusplus >= 201703L
44 optional() : has_value_(
false), value_() {}
45 optional(
const T& value) : has_value_(
true), value_(value) {}
48 has_value()
const noexcept
57 throw std::runtime_error(
"bad_optional_access");
62 value_or(
const T& default_value)
const
70 operator*()
const&
noexcept
74 operator*() &
noexcept
78 operator->()
const noexcept
86 operator=(
const T& value)
93 explicit operator bool()
const noexcept {
return has_value(); }
96template <
typename T,
typename U>
100 if (!lhs.has_value() && !rhs.has_value())
102 if (!lhs.has_value() || !rhs.has_value())
104 return lhs.value() == rhs.value();
107template <
typename T,
typename U>
109operator!=(
const optional<T>& lhs,
const optional<U>& rhs)
111 return !(lhs == rhs);
Simplified implementation of std::optional just enough to be used as a replacement for our purposes a...