38 using safe_bool = void (
optional::*)()
const;
47 optional(T
const &arg) : has_value_(true), value_(arg) {}
58 value_ = other.
value();
66 }
else if (!
has_value() && rhs.has_value()) {
69 }
else if (
has_value() && !rhs.has_value()) {
70 rhs.initialize(**
this);
85 operator safe_bool()
const {
return has_value() ? &optional::this_type_does_not_support_comparisons :
nullptr; }
97 void reset() { has_value_ =
false; }
100 void this_type_does_not_support_comparisons()
const {}
102 template<
typename V>
void initialize(V
const &
value) {
107 bool has_value_{
false};
114 return bool(
x) != bool(
y) ? false : !bool(
x) ? true : *
x == *
y;
122 return (!
y) ? false : (!
x) ?
true : *
x < *
y;
160 return bool(
x) ? *
x == v :
false;
164 return bool(
x) ? v == *
x :
false;
168 return bool(
x) ? *
x != v :
true;
172 return bool(
x) ? v != *
x :
true;
176 return bool(
x) ? *
x < v :
true;
180 return bool(
x) ? v < *
x :
false;
184 return bool(
x) ? *
x <= v :
true;
188 return bool(
x) ? v <= *
x :
false;
192 return bool(
x) ? *
x > v :
false;
196 return bool(
x) ? v > *
x :
true;
200 return bool(
x) ? *
x >= v :
false;
204 return bool(
x) ? v >= *
x :
true;
value_type value_or(U const &v) const
void swap(optional &rhs) noexcept
optional & operator=(optional< U > const &other)
optional(optional< U > const &other)
optional & operator=(nullopt_t)
value_type const & value() const
value_type * operator->()
value_type const & operator*() const
value_type const * operator->() const
Providing packet encoding functions for exchanging data with a remote host.
bool operator>=(optional< T > const &x, optional< U > const &y)
bool operator==(optional< T > const &x, optional< U > const &y)
void swap(optional< T > &x, optional< T > &y) noexcept
bool operator!=(optional< T > const &x, optional< U > const &y)
bool operator>(optional< T > const &x, optional< U > const &y)
bool operator<(optional< T > const &x, optional< U > const &y)
bool operator<=(optional< T > const &x, optional< U > const &y)
optional< T > make_optional(T const &v)
const nullopt_t nullopt((nullopt_t::init()))