51 present_ = o.present_;
71 const T* operator->()
const {
75 const T& operator*()
const {
79 operator bool()
const {
83 bool is_present()
const {
87 bool has_value()
const noexcept {
94 throw std::runtime_error(
"Access optional value, which has not been set");
100 const T &value()
const &{
102 throw std::runtime_error(
"Access optional value, which has not been set");
109 throw std::runtime_error(
"Access optional value, which has not been set");
111 return std::move(value_);
114 const T &&value()
const &&{
116 throw std::runtime_error(
"Access optional value, which has not been set");
118 return std::move(value_);
122 return this->value();
126 return this->value();
128 const T &get()
const & {
129 return this->value();
132 const T&& get()
const &&{
133 return this->value();
136 T value_or(U &&default_value)
const &{
137 return bool(*
this) ? **this :
static_cast<T
>(std::forward<U>(default_value));
141 T value_or(U &&default_value) &&{
142 return bool(*
this) ? std::move(**
this) :
static_cast<T
>(std::forward<U>(default_value));
152 void set(
const T& v) {