![]() |
v8 13.6.233 (node 24.1.0)
V8 is Google's open source JavaScript engine
|
#include <v8-maybe.h>
Public Member Functions | |
V8_INLINE bool | IsNothing () const |
V8_INLINE bool | IsJust () const |
V8_INLINE T | ToChecked () const |
V8_INLINE void | Check () const |
V8_WARN_UNUSED_RESULT V8_INLINE bool | To (T *out) const |
V8_INLINE T | FromJust () const & |
V8_INLINE T | FromJust () && |
V8_INLINE T | FromMaybe (const T &default_value) const |
V8_INLINE bool | operator== (const Maybe &other) const |
V8_INLINE bool | operator!= (const Maybe &other) const |
![]() | |
CPPGC_STACK_ALLOCATED () | |
Friends | |
template<class U> | |
Maybe< U > | Nothing () |
template<class U> | |
Maybe< U > | Just (const U &u) |
template<class U, std::enable_if_t<!std::is_lvalue_reference_v< U > > *> | |
Maybe< U > | Just (U &&u) |
A simple Maybe type, representing an object which may or may not have a value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
If an API method returns a Maybe<>, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasn't been caught yet, or because a TerminateExecution exception was thrown. In that case, a "Nothing" value is returned.
Definition at line 33 of file v8-maybe.h.
|
inline |
Short-hand for ToChecked(), which doesn't return a value. To be used, where the actual value of the Maybe is not needed like Object::Set.
Definition at line 47 of file v8-maybe.h.
References v8::api_internal::FromJustIsNothing(), IsJust(), V8_INLINE, and V8_UNLIKELY.
|
inline |
Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), V8 will crash the process.
Definition at line 73 of file v8-maybe.h.
References v8::api_internal::FromJustIsNothing(), IsJust(), V8_INLINE, and V8_UNLIKELY.
|
inline |
Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), V8 will crash the process.
Definition at line 64 of file v8-maybe.h.
References v8::api_internal::FromJustIsNothing(), IsJust(), V8_INLINE, and V8_UNLIKELY.
Referenced by operator==(), and ToChecked().
|
inline |
Converts this Maybe<> to a value of type T, using a default value if this Maybe<> is nothing (empty).
Definition at line 82 of file v8-maybe.h.
References V8_INLINE.
|
inline |
Definition at line 36 of file v8-maybe.h.
References V8_INLINE.
Referenced by Check(), FromJust(), FromJust(), operator==(), Maybe< void >::operator==(), and To().
|
inline |
Definition at line 35 of file v8-maybe.h.
References V8_INLINE.
Definition at line 91 of file v8-maybe.h.
References operator==(), and V8_INLINE.
Definition at line 86 of file v8-maybe.h.
References FromJust(), IsJust(), and V8_INLINE.
Referenced by operator!=(), and Maybe< void >::operator!=().
|
inline |
Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), |false| is returned and |out| is left untouched.
Definition at line 55 of file v8-maybe.h.
References IsJust(), V8_INLINE, V8_LIKELY, and V8_WARN_UNUSED_RESULT.
|
inline |
An alias for |FromJust|. Will crash if the Maybe<> is nothing.
Definition at line 41 of file v8-maybe.h.
References FromJust(), and V8_INLINE.
|
friend |
Definition at line 112 of file v8-maybe.h.