|
libcaf
0.14.4
|
Represents a computation returning either T or std::error_condition.
More...
#include <maybe.hpp>
Public Types | |
| using | type = typename std::remove_reference< T >::type |
| using | reference = type & |
| using | const_reference = const type & |
| using | pointer = type * |
| using | const_pointer = const type * |
| using | error_type = std::error_condition |
| using | storage = typename std::conditional< std::is_reference< T >::value, std::reference_wrapper< type >, T >::type |
| Type for storing values. | |
Public Member Functions | |
| maybe (error_type err) | |
| Creates an instance representing an error. | |
| maybe (T value) | |
Creates an instance representing value. | |
| template<class E , class = typename std::enable_if< std::is_error_condition_enum<E>::value >::type> | |
| maybe (E error_code_enum) | |
| Creates an instance representing an error from an error condition enum. More... | |
| maybe () | |
| Creates an empty instance. | |
| maybe (const none_t &) | |
| Creates an empty instance. | |
| maybe (const maybe &other) | |
| maybe (maybe &&other) | |
| template<class U > | |
| maybe (maybe< U > &&other) | |
| template<class U > | |
| maybe (const maybe< U > &other) | |
| maybe & | operator= (const none_t &) |
| maybe & | operator= (T value) |
| maybe & | operator= (error_type err) |
| template<class E , class = typename std::enable_if< std::is_error_condition_enum<E>::value >::type> | |
| maybe & | operator= (E error_code_enum) |
| maybe & | operator= (maybe &&other) |
| maybe & | operator= (const maybe &other) |
| template<class U > | |
| maybe & | operator= (maybe< U > &&other) |
| template<class U > | |
| maybe & | operator= (const maybe< U > &other) |
| bool | available () const |
| Queries whether this instance holds a value. | |
| operator bool () const | |
Returns available(). | |
| bool | operator! () const |
Returns ! available(). | |
| reference | get () |
| Returns the value. | |
| const_reference | get () const |
| Returns the value. | |
| reference | operator* () |
| Returns the value. | |
| const_reference | operator* () const |
| Returns the value. | |
| pointer | operator-> () |
| Returns a pointer to the value. | |
| const_pointer | operator-> () const |
| Returns a pointer to the value. | |
| bool | empty () const |
| Returns whether this objects holds neither a value nor an actual error. | |
| const error_type & | error () const |
| Returns the error. | |
Related Functions | |
(Note that these are not member functions.) | |
| template<class T , typename U > | |
| bool | operator== (const maybe< T > &lhs, const maybe< U > &rhs) |
Returns true if both objects represent either the same value or the same error, false otherwise. | |
| template<class T , typename U > | |
| bool | operator== (const T &lhs, const maybe< U > &rhs) |
Returns true if rhs is available and its value is equal to lhs. | |
| template<class T , typename U > | |
| bool | operator!= (const maybe< T > &lhs, const maybe< U > &rhs) |
Returns true if the objects represent different values or errors, false otherwise. | |
| template<class T , typename U > | |
| bool | operator!= (const maybe< T > &lhs, const U &rhs) |
Returns true if lhs is not available or its value is not equal to rhs. | |
| template<class T , typename U > | |
| bool | operator!= (const T &lhs, const maybe< U > &rhs) |
Returns true if rhs is not available or its value is not equal to lhs. | |
| template<class T > | |
| bool | operator== (const maybe< T > &val, const std::error_condition &err) |
Returns ! val.available() && val.error() == err. | |
| template<class T > | |
| bool | operator== (const std::error_condition &err, const maybe< T > &val) |
Returns ! val.available() && val.error() == err. | |
| template<class T > | |
| bool | operator!= (const maybe< T > &val, const std::error_condition &err) |
Returns val.available() || val.error() != err. | |
| template<class T > | |
| bool | operator!= (const std::error_condition &err, const maybe< T > &val) |
Returns val.available() || val.error() != err. | |
| template<class T > | |
| bool | operator== (const maybe< T > &val, const none_t &) |
Returns val.empty(). | |
| template<class T > | |
| bool | operator== (const none_t &, const maybe< T > &val) |
Returns val.empty(). | |
| template<class T > | |
| bool | operator!= (const maybe< T > &val, const none_t &) |
Returns ! val.empty(). | |
| template<class T > | |
| bool | operator!= (const none_t &, const maybe< T > &val) |
Returns ! val.empty(). | |
Represents a computation returning either T or std::error_condition.
Note that the error condition might be default-constructed. In this case, a maybe represents simply none. Hence, this type has three possible states:
T is availableavailable() returns trueempty() returns falseerror() evaluates to falseavailable() returns falseempty() returns trueerror() evaluates to falseavailable() returns falseempty() returns falseerror() evaluates to true | caf::maybe< T >::maybe | ( | E | error_code_enum | ) |
Creates an instance representing an error from an error condition enum.
1.8.9.1