5#ifndef INCLUDE_V8_MAYBE_H_
6#define INCLUDE_V8_MAYBE_H_
11#include "cppgc/internal/conditional-stack-allocated.h"
29
30
31
32
33
34
35
36
37
49
50
51
55
56
60
61
62
68
69
70
77
78
79
80
87
88
89
96
97
98
101 return std::move(value_);
105
106
107
109 return has_value_ ? value_ : default_value;
113 return (
IsJust() == other.IsJust()) &&
114 (!
IsJust() || FromJust() == other.FromJust());
122 explicit Maybe(
const T& t) : has_value_(
true), value_(t) {}
123 explicit Maybe(T&& t) : has_value_(
true), value_(std::move(t)) {}
125 bool has_value_ =
false;
130 template <
class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
147template <
class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* =
nullptr>
149 return Maybe<T>(std::move(t));
174 explicit Maybe(JustTag) : is_valid_(
true) {}
176 bool is_valid_ =
false;
friend Maybe< void > JustVoid()
V8_INLINE bool IsEmpty() const
V8_INLINE bool IsNothing() const
V8_INLINE bool operator!=(const Maybe &other) const
constexpr Maybe()=default
constexpr Maybe(internal::NullMaybeType)
V8_INLINE bool operator==(const Maybe &other) const
V8_INLINE bool IsJust() const
V8_INLINE bool IsEmpty() const
V8_INLINE bool IsNothing() const
friend Maybe< U > Just(U &&u)
V8_INLINE bool operator!=(const Maybe &other) const
V8_INLINE T FromJust() &&
constexpr Maybe()=default
V8_WARN_UNUSED_RESULT V8_INLINE bool MoveTo(T *out) &&
V8_INLINE Maybe(internal::NullMaybeType)
V8_WARN_UNUSED_RESULT V8_INLINE bool To(T *out) const
V8_INLINE void Check() const
friend Maybe< U > Just(const U &u)
V8_INLINE T FromJust() const &
V8_INLINE bool operator==(const Maybe &other) const
V8_INLINE bool IsJust() const
V8_INLINE T ToChecked() const
V8_INLINE T FromMaybe(const T &default_value) const
V8_EXPORT void FromJustIsNothing()
constexpr NullMaybeType kNullMaybe
Maybe< T > Just(const T &t)
constexpr Maybe< T > Nothing()
#define V8_LIKELY(condition)
#define V8_WARN_UNUSED_RESULT
#define V8_UNLIKELY(condition)