79 requires std::is_reference_v<T>
84 static constexpr char errorMsg[] =
"optional<T &>: access error";
96 constexpr
optional(std::nullopt_t noOption) noexcept;
137 optional &operator=(std::nullopt_t noOption) noexcept;
142 void reset() noexcept;
148 [[nodiscard]] constexpr
bool has_value() const noexcept;
154 [[nodiscard]] constexpr explicit operator
bool() const noexcept;
177 const T operator*() const;
204 requires std::is_reference_v<T>
211 requires std::is_reference_v<T>
218 requires std::is_reference_v<T>
225 requires std::is_reference_v<T>
233 requires std::is_reference_v<T>
240 requires std::is_reference_v<T>
243 return mRef !=
nullptr;
247 requires std::is_reference_v<T>
254 requires std::is_reference_v<T>
263 requires std::is_reference_v<T>
266 return bool(*
this) ? *
mRef : default_value;
270 requires std::is_reference_v<T>
279 requires std::is_reference_v<T>
282 return const_cast<T &
>(*(std::as_const(*
this)));
286 requires std::is_reference_v<T>
295 requires std::is_reference_v<T>
298 return const_cast<value_type *
>(std::as_const(*this).operator->());
designed to represent an optional reference to an object of type T
optional & operator=(const optional &) noexcept=default
Copy assignment operator.
const T operator*() const
Dereference operator.
void reset() noexcept
Resets the optional, making it empty.
std::remove_reference_t< T > value_type
constexpr value_type value() const
Gets the contained value.
constexpr bool has_value() const noexcept
Checks whether the optional contains a value.
constexpr optional() noexcept=default
Default constructor. Creates an empty optional.
const value_type * operator->() const
Arrow operator.
static constexpr char errorMsg[]
constexpr value_type value_or(const value_type &default_value) const noexcept
Returns the contained value if the optional is not empty, otherwise returns the provided default valu...