libcaf  0.13.2
Public Types | Public Member Functions | Related Functions | List of all members
caf::optional< T > Class Template Reference

Represents an optional value of T. More...

#include <optional.hpp>

Public Types

using type = T
 Typdef for T.
 

Public Member Functions

 optional (const none_t &=none)
 Creates an empty instance with valid() == false.
 
 optional (T value)
 Creates an valid instance from value.
 
 optional (const optional &other)
 
 optional (optional &&other)
 
optionaloperator= (const optional &other)
 
optionaloperator= (optional &&other)
 
bool valid () const
 Queries whether this instance holds a value.
 
bool empty () const
 Returns !valid().
 
 operator bool () const
 Returns valid().
 
bool operator! () const
 Returns !valid().
 
T & operator* ()
 Returns the value.
 
const T & operator* () const
 Returns the value.
 
const T * operator-> () const
 Returns the value.
 
T * operator-> ()
 Returns the value.
 
T & get ()
 Returns the value.
 
const T & get () const
 Returns the value.
 
const T & get_or_else (const T &default_value) const
 Returns the value if valid(), otherwise returns default_value.
 

Related Functions

(Note that these are not member functions.)

template<class T , typename U >
bool operator== (const optional< T > &lhs, const optional< U > &rhs)
 
template<class T , typename U >
bool operator== (const optional< T > &lhs, const U &rhs)
 
template<class T , typename U >
bool operator== (const T &lhs, const optional< U > &rhs)
 
template<class T , typename U >
bool operator!= (const optional< T > &lhs, const optional< U > &rhs)
 
template<class T , typename U >
bool operator!= (const optional< T > &lhs, const U &rhs)
 
template<class T , typename U >
bool operator!= (const T &lhs, const optional< U > &rhs)
 
template<class T >
bool operator== (const optional< T > &val, const none_t &)
 
template<class T >
bool operator== (const none_t &, const optional< T > &val)
 
template<class T >
bool operator!= (const optional< T > &lhs, const none_t &rhs)
 
template<class T >
bool operator!= (const none_t &lhs, const optional< T > &rhs)
 
template<class T >
std::string to_string (const optional< T > &what)
 

Detailed Description

template<class T>
class caf::optional< T >

Represents an optional value of T.

Friends And Related Function Documentation

template<class T , typename U >
bool operator!= ( const optional< T > &  lhs,
const optional< U > &  rhs 
)
related
template<class T , typename U >
bool operator!= ( const optional< T > &  lhs,
const U &  rhs 
)
related
template<class T , typename U >
bool operator!= ( const T &  lhs,
const optional< U > &  rhs 
)
related
template<class T >
bool operator!= ( const optional< T > &  lhs,
const none_t &  rhs 
)
related
template<class T >
bool operator!= ( const none_t &  lhs,
const optional< T > &  rhs 
)
related
template<class T , typename U >
bool operator== ( const optional< T > &  lhs,
const optional< U > &  rhs 
)
related
template<class T , typename U >
bool operator== ( const optional< T > &  lhs,
const U &  rhs 
)
related
template<class T , typename U >
bool operator== ( const T &  lhs,
const optional< U > &  rhs 
)
related
template<class T >
bool operator== ( const optional< T > &  val,
const none_t &   
)
related
template<class T >
bool operator== ( const none_t &  ,
const optional< T > &  val 
)
related
template<class T >
std::string to_string ( const optional< T > &  what)
related

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