5#ifndef INCLUDE_V8_MAYBE_H_
6#define INCLUDE_V8_MAYBE_H_
17namespace api_internal {
75 return std::move(value_);
83 return has_value_ ? value_ : default_value;
96 Maybe() : has_value_(false) {}
97 explicit Maybe(
const T& t) : has_value_(true), value_(t) {}
98 explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
107 template <
class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
124template <
class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* =
nullptr>
147 Maybe() : is_valid_(false) {}
148 explicit Maybe(JustTag) : is_valid_(true) {}
Definition: conditional-stack-allocated.h:19
bool operator==(const Maybe &other) const
Definition: v8-maybe.h:136
bool IsNothing() const
Definition: v8-maybe.h:133
bool operator!=(const Maybe &other) const
Definition: v8-maybe.h:140
bool IsJust() const
Definition: v8-maybe.h:134
Definition: v8-maybe.h:33
friend Maybe< U > Nothing()
Definition: v8-maybe.h:112
T FromMaybe(const T &default_value) const
Definition: v8-maybe.h:82
bool operator!=(const Maybe &other) const
Definition: v8-maybe.h:91
bool IsNothing() const
Definition: v8-maybe.h:35
T FromJust() const &
Definition: v8-maybe.h:64
friend Maybe< U > Just(U &&u)
T FromJust() &&
Definition: v8-maybe.h:73
void Check() const
Definition: v8-maybe.h:47
bool To(T *out) const
Definition: v8-maybe.h:55
friend Maybe< U > Just(const U &u)
bool IsJust() const
Definition: v8-maybe.h:36
bool operator==(const Maybe &other) const
Definition: v8-maybe.h:86
T ToChecked() const
Definition: v8-maybe.h:41
Definition: libplatform.h:15
Maybe< T > Nothing()
Definition: v8-maybe.h:112
Maybe< void > JustVoid()
Definition: v8-maybe.h:157
Maybe< T > Just(const T &t)
Definition: v8-maybe.h:117
#define V8_EXPORT
Definition: v8config.h:800
#define V8_INLINE
Definition: v8config.h:500
#define V8_LIKELY(condition)
Definition: v8config.h:661
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:671
#define V8_UNLIKELY(condition)
Definition: v8config.h:660