Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
v8::Maybe< T > Class Template Reference

#include <v8-maybe.h>

Public Member Functions

bool IsNothing () const
 
bool IsJust () const
 
ToChecked () const
 
void Check () const
 
bool To (T *out) const
 
FromJust () const &
 
FromJust () &&
 
FromMaybe (const T &default_value) const
 
bool operator== (const Maybe &other) const
 
bool operator!= (const Maybe &other) const
 

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)
 

Detailed Description

template<class T>
class v8::Maybe< T >

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.

Member Function Documentation

◆ Check()

template<class T >
void v8::Maybe< T >::Check ( ) const
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.

Here is the call graph for this function:

◆ FromJust() [1/2]

template<class T >
T v8::Maybe< T >::FromJust ( ) &&
inline

Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), V8 will crash the process.

Here is the call graph for this function:

◆ FromJust() [2/2]

template<class T >
T v8::Maybe< T >::FromJust ( ) const &
inline

Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), V8 will crash the process.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FromMaybe()

template<class T >
T v8::Maybe< T >::FromMaybe ( const T &  default_value) const
inline

Converts this Maybe<> to a value of type T, using a default value if this Maybe<> is nothing (empty).

◆ IsJust()

template<class T >
bool v8::Maybe< T >::IsJust ( ) const
inline
Here is the caller graph for this function:

◆ IsNothing()

template<class T >
bool v8::Maybe< T >::IsNothing ( ) const
inline

◆ operator!=()

template<class T >
bool v8::Maybe< T >::operator!= ( const Maybe< T > &  other) const
inline
Here is the call graph for this function:

◆ operator==()

template<class T >
bool v8::Maybe< T >::operator== ( const Maybe< T > &  other) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ To()

template<class T >
bool v8::Maybe< T >::To ( T *  out) const
inline

Converts this Maybe<> to a value of type T. If this Maybe<> is nothing (empty), |false| is returned and |out| is left untouched.

Here is the call graph for this function:

◆ ToChecked()

template<class T >
T v8::Maybe< T >::ToChecked ( ) const
inline

An alias for |FromJust|. Will crash if the Maybe<> is nothing.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ Just [1/2]

template<class T >
template<class U >
Maybe< U > Just ( const U &  u)
friend

◆ Just [2/2]

template<class T >
template<class U , std::enable_if_t<!std::is_lvalue_reference_v< U > > * >
Maybe< U > Just ( U &&  u)
friend

◆ Nothing

template<class T >
template<class U >
Maybe< U > Nothing ( )
friend

The documentation for this class was generated from the following file: