Calico
 All Classes Namespaces Files Functions Variables Typedefs Friends Groups
cal::optional< T > Class Template Reference

Represents an optional value. More...

#include <optional.hpp>

Public Member Functions

 optional ()
 Creates a disengaged optional value.
 
 optional (nullopt_t)
 Creates a disengaged optional value.
 
 optional (const T &value)
 Creates an engaged optional value.
 
 operator bool () const
 Returns whether the optional is engaged.
 
optionaloperator= (nullopt_t)
 Disengages the value from the optional.
 
template<class U >
optionaloperator= (const U &value)
 Assigns a value to the optional.
 
const T & value () const
 Extracts the value from the optional. If there is none, an std::logic_error is thrown.
 
T & value ()
 Extracts the value from the optional. If there is none, an std::logic_error is thrown.
 
template<class U >
value_or (const U &value) const
 Returns the value of the optional if it exists, or the given value argument otherwise.
 

Detailed Description

template<class T>
class cal::optional< T >

Represents an optional value.