Arbiter
Dependency manager library that supports decentralization
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Arbiter::Optional< T > Struct Template Referencefinal

Represents a value which may or may not exist. More...

Public Types

using Value = T
 

Public Member Functions

constexpr Optional () noexcept
 Creates an empty Optional. More...
 
 Optional (const None &) noexcept
 Creates an empty Optional. More...
 
 Optional (const T &value) noexcept(std::is_nothrow_copy_constructible< T >::value)
 Creates an Optional containing a copy of the given value. More...
 
 Optional (T &&value) noexcept(std::is_nothrow_move_constructible< T >::value)
 Creates an Optional containing the given value. More...
 
 Optional (const Optional &other) noexcept(std::is_nothrow_copy_constructible< T >::value)
 
template<typename U >
 Optional (const Optional< U > &other) noexcept(std::is_nothrow_constructible< T, const U &>::value)
 Converts from another Optional containing a compatible type. More...
 
 Optional (Optional &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
 
template<typename U >
 Optional (Optional< U > &&other) noexcept(std::is_nothrow_constructible< T, U &&>::value)
 Converts from another Optional containing a compatible type. More...
 
 ~Optional () noexcept(std::is_nothrow_destructible< T >::value)
 
 operator bool () const noexcept
 Returns true if this Optional contains a value, or false if it is empty. More...
 
T & operator* () noexcept
 
const T & operator* () const noexcept
 
T * operator-> () noexcept
 
const T * operator-> () const noexcept
 
Optionaloperator= (const Optional &other) noexcept(std::is_nothrow_destructible< T >::value &&std::is_nothrow_copy_constructible< T >::value)
 
Optionaloperator= (Optional &&other) noexcept(std::is_nothrow_destructible< T >::value &&std::is_nothrow_move_constructible< T >::value)
 
T * pointer () noexcept
 Returns a pointer to the value in the Optional, or nullptr if empty. More...
 
const T * pointer () const noexcept
 Returns a pointer to the value in the Optional, or nullptr if empty. More...
 
T & value () noexcept
 Accesses the value in the Optional. More...
 
const T & value () const noexcept
 Accesses the value in the Optional. More...
 

Static Public Member Functions

static Optional fromPointer (const T *pointer) noexcept(std::is_nothrow_copy_constructible< T >::value)
 Creates an Optional from a pointer which may or may not be null. More...
 

Detailed Description

template<typename T>
struct Arbiter::Optional< T >

Represents a value which may or may not exist.

Definition at line 25 of file Optional.h.

Member Typedef Documentation

§ Value

template<typename T>
using Arbiter::Optional< T >::Value = T

Definition at line 28 of file Optional.h.

Constructor & Destructor Documentation

§ Optional() [1/8]

template<typename T>
constexpr Arbiter::Optional< T >::Optional ( )
noexcept

Creates an empty Optional.

Definition at line 33 of file Optional.h.

§ Optional() [2/8]

template<typename T>
Arbiter::Optional< T >::Optional ( const None )
noexcept

Creates an empty Optional.

Definition at line 40 of file Optional.h.

§ Optional() [3/8]

template<typename T>
Arbiter::Optional< T >::Optional ( const T &  value)
noexcept

Creates an Optional containing a copy of the given value.

Definition at line 47 of file Optional.h.

§ Optional() [4/8]

template<typename T>
Arbiter::Optional< T >::Optional ( T &&  value)
noexcept

Creates an Optional containing the given value.

Definition at line 56 of file Optional.h.

§ Optional() [5/8]

template<typename T>
Arbiter::Optional< T >::Optional ( const Optional< T > &  other)
noexcept

Definition at line 62 of file Optional.h.

§ Optional() [6/8]

template<typename T>
template<typename U >
Arbiter::Optional< T >::Optional ( const Optional< U > &  other)
noexcept

Converts from another Optional containing a compatible type.

Definition at line 74 of file Optional.h.

§ Optional() [7/8]

template<typename T>
Arbiter::Optional< T >::Optional ( Optional< T > &&  other)
noexcept

Definition at line 97 of file Optional.h.

§ Optional() [8/8]

template<typename T>
template<typename U >
Arbiter::Optional< T >::Optional ( Optional< U > &&  other)
noexcept

Converts from another Optional containing a compatible type.

Definition at line 109 of file Optional.h.

§ ~Optional()

template<typename T>
Arbiter::Optional< T >::~Optional ( )
noexcept

Definition at line 128 of file Optional.h.

Member Function Documentation

§ fromPointer()

template<typename T>
static Optional Arbiter::Optional< T >::fromPointer ( const T *  pointer)
staticnoexcept

Creates an Optional from a pointer which may or may not be null.

Definition at line 136 of file Optional.h.

§ operator bool()

template<typename T>
Arbiter::Optional< T >::operator bool ( ) const
explicitnoexcept

Returns true if this Optional contains a value, or false if it is empty.

Definition at line 148 of file Optional.h.

§ operator*() [1/2]

template<typename T>
T& Arbiter::Optional< T >::operator* ( )
noexcept

Definition at line 191 of file Optional.h.

§ operator*() [2/2]

template<typename T>
const T& Arbiter::Optional< T >::operator* ( ) const
noexcept

Definition at line 196 of file Optional.h.

§ operator->() [1/2]

template<typename T>
T* Arbiter::Optional< T >::operator-> ( )
noexcept

Definition at line 201 of file Optional.h.

§ operator->() [2/2]

template<typename T>
const T* Arbiter::Optional< T >::operator-> ( ) const
noexcept

Definition at line 206 of file Optional.h.

§ operator=() [1/2]

template<typename T>
Optional& Arbiter::Optional< T >::operator= ( const Optional< T > &  other)
noexcept

Definition at line 82 of file Optional.h.

§ operator=() [2/2]

template<typename T>
Optional& Arbiter::Optional< T >::operator= ( Optional< T > &&  other)
noexcept

Definition at line 117 of file Optional.h.

§ pointer() [1/2]

template<typename T>
T* Arbiter::Optional< T >::pointer ( )
noexcept

Returns a pointer to the value in the Optional, or nullptr if empty.

Definition at line 178 of file Optional.h.

§ pointer() [2/2]

template<typename T>
const T* Arbiter::Optional< T >::pointer ( ) const
noexcept

Returns a pointer to the value in the Optional, or nullptr if empty.

Definition at line 186 of file Optional.h.

§ value() [1/2]

template<typename T>
T& Arbiter::Optional< T >::value ( )
noexcept

Accesses the value in the Optional.

The Optional must not be empty.

Definition at line 158 of file Optional.h.

§ value() [2/2]

template<typename T>
const T& Arbiter::Optional< T >::value ( ) const
noexcept

Accesses the value in the Optional.

The Optional must not be empty.

Definition at line 169 of file Optional.h.


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