5#ifndef INCLUDE_V8_MAYBE_H_
6#define INCLUDE_V8_MAYBE_H_
16namespace api_internal {
74 return std::move(value_);
82 return has_value_ ? value_ : default_value;
95 Maybe() : has_value_(false) {}
96 explicit Maybe(
const T& t) : has_value_(true), value_(t) {}
97 explicit Maybe(T&& t) : has_value_(true), value_(std::move(t)) {}
106 template <
class U, std::enable_if_t<!std::is_lvalue_reference_v<U>>*>
123template <
class T, std::enable_if_t<!std::is_lvalue_reference_v<T>>* =
nullptr>
146 Maybe() : is_valid_(false) {}
147 explicit Maybe(JustTag) : is_valid_(true) {}
bool operator==(const Maybe &other) const
Definition: v8-maybe.h:135
bool IsNothing() const
Definition: v8-maybe.h:132
bool operator!=(const Maybe &other) const
Definition: v8-maybe.h:139
bool IsJust() const
Definition: v8-maybe.h:133
Definition: v8-maybe.h:32
friend Maybe< U > Nothing()
Definition: v8-maybe.h:111
T FromMaybe(const T &default_value) const
Definition: v8-maybe.h:81
bool operator!=(const Maybe &other) const
Definition: v8-maybe.h:90
bool IsNothing() const
Definition: v8-maybe.h:34
T FromJust() const &
Definition: v8-maybe.h:63
friend Maybe< U > Just(U &&u)
T FromJust() &&
Definition: v8-maybe.h:72
void Check() const
Definition: v8-maybe.h:46
bool To(T *out) const
Definition: v8-maybe.h:54
friend Maybe< U > Just(const U &u)
bool IsJust() const
Definition: v8-maybe.h:35
bool operator==(const Maybe &other) const
Definition: v8-maybe.h:85
T ToChecked() const
Definition: v8-maybe.h:40
Definition: libplatform.h:15
Maybe< T > Nothing()
Definition: v8-maybe.h:111
Maybe< void > JustVoid()
Definition: v8-maybe.h:156
Maybe< T > Just(const T &t)
Definition: v8-maybe.h:116
#define V8_EXPORT
Definition: v8config.h:793
#define V8_INLINE
Definition: v8config.h:499
#define V8_LIKELY(condition)
Definition: v8config.h:650
#define V8_WARN_UNUSED_RESULT
Definition: v8config.h:660
#define V8_UNLIKELY(condition)
Definition: v8config.h:649